function.curl-exec

function.curl-exec

[code=python] ¶
import httplib ¶
h = 'www.example.com' ¶
f = httplib.HTTPConnection(h) ¶
f.request("GET",'/') ¶
f.getresponse().read() ¶
[/code] ¶

Alternative using pycurl: ¶

[code=python] ¶
import pycurl ¶
import StringIO ¶
b = StringIO.StringIO() ¶
c = pycurl.Curl() ¶
c.setopt(pycurl.URL, 'www.example.com') ¶
c.setopt(pycurl.WRITEFUNCTION, b.write) ¶
c.perform() ¶
response = b.getvalue() ¶
c.close()