HTTP: Difference between revisions

Content added Content deleted
(code -> lang)
(code to lang)
Line 131: Line 131:
=={{header|Python}}==
=={{header|Python}}==


<code python>
<lang python>import urllib
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()</lang>
</code>


<code python>
<lang python>import urllib
import urllib
print urllib.urlopen("http://rosettacode.org").read()
print urllib.urlopen("http://rosettacode.org").read()
</code>
</lang>


=={{header|Ruby}}==
=={{header|Ruby}}==


<code ruby>
<lang ruby>require 'open-uri'
require 'open-uri'
require 'kconv'
require 'kconv'


puts open("http://rosettacode.org").read
puts open("http://rosettacode.org").read</lang>
</code>


=={{header|Tcl}}==
=={{header|Tcl}}==

<code tcl>
package require http
<lang tcl>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]</lang>
</code>


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==

<code bash>
wget http://www.rosettacode.org -O tmp -o /dev/null
<code bash>wget http://www.rosettacode.org -O tmp -o /dev/null
cat tmp
cat tmp
rm tmp
rm tmp</code>

</code>
<lang bash>
or
curl -s http://www.rosettacode.org/</lang>
<code bash>
curl -s http://www.rosettacode.org/
</code>