How can I get the content of a web site using http library

S

silverburgh.meryl

I am trying to get the content of a web site like this:
But my question is how can I do a 'GET' request without putting the '/
index.html''


h = httplib.HTTP('www.yahoo.com')

# it takes 2 arguments here, but I don't know if the site has
'/index.html' , how can I leave this out?

h.putrequest('GET')
h.endheaders()

errcode, errmsg, headers = h.getreply()

if (errcode == 200):

f = h.getfile()

Thank you for your help.
 
K

kyosohma

I am trying to get the content of a web site like this:
But my question is how can I do a 'GET' request without putting the '/
index.html''

h = httplib.HTTP('www.yahoo.com')

# it takes 2 arguments here, but I don't know if the site has
'/index.html' , how can I leave this out?

h.putrequest('GET')
h.endheaders()

errcode, errmsg, headers = h.getreply()

if (errcode == 200):

f = h.getfile()

Thank you for your help.

You may want to go with the urllib module instead. Check out the how-
to below:

http://www.voidspace.org.uk/python/articles/urllib2.shtml

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top