HTTP: Difference between revisions
Content added Content deleted
No edit summary |
m (<code> now allows reasonable placement of the tags (and <pre> always allowed it anyway)) |
||
Line 100: | Line 100: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
<code java> |
<code java> |
||
import java.util.Scanner; |
|||
import java.net.URL; |
import java.net.URL; |
||
Line 109: | Line 110: | ||
while( sc.hasNext() ) System.out.println(sc.nextLine()); |
while( sc.hasNext() ) System.out.println(sc.nextLine()); |
||
} |
} |
||
} |
|||
</code> |
|||
Apache Commons IO |
Apache Commons IO |
||
<code java> |
<code java> |
||
import org.apache.commons.io.IOUtils; |
|||
import java.net.*; |
import java.net.*; |
||
Line 120: | Line 123: | ||
IOUtils.copy(new URL("http://rosettacode.org").openStream(),System.out); |
IOUtils.copy(new URL("http://rosettacode.org").openStream(),System.out); |
||
} |
} |
||
} |
|||
</code> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
<code perl> |
<code perl> |
||
using LWP::Simple; |
|||
print get("http://www.rosettacode.org"); |
print get("http://www.rosettacode.org"); |
||
</code> |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |
||
<code php> |
|||
print(file_get_contents("http://www.rosettacode.org")); |
|||
</code> |
|||
=={{header|Python}}== |
=={{header|Python}}== |
||
<code python> |
<code python> |
||
import urllib |
|||
url = urllib.urlopen("http://www.rosettacode.org") |
url = urllib.urlopen("http://www.rosettacode.org") |
||
print url.read() |
print url.read() |
||
url.close() |
url.close() |
||
</code> |
|||
<code python> |
<code python> |
||
import urllib |
|||
print urllib.urlopen("http://rosettacode.org").read() |
print urllib.urlopen("http://rosettacode.org").read() |
||
</code> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
<code ruby> |
<code ruby> |
||
require 'open-uri' |
|||
require 'kconv' |
require 'kconv' |
||
puts open("http://rosettacode.org").read |
puts open("http://rosettacode.org").read |
||
</code> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
<pre> |
|||
package require http |
|||
set request [http::geturl "http://www.rosettacode.org"] |
set request [http::geturl "http://www.rosettacode.org"] |
||
puts [http::data $request] |
puts [http::data $request] |
||
</pre> |
|||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
<code bash> |
|||
wget http://www.rosettacode.org -O tmp -o /dev/null |
|||
cat tmp |
cat tmp |
||
rm tmp |
rm tmp |
||
</code> |
|||
or |
or |
||
<code bash> |
|||
curl -s http://www.rosettacode.org/ |
|||
</code> |