Why doesn't this work?
Dr. Peter Stoehr
peter.stoehr at weihenstephan.org
Mon Dec 27 17:08:03 EST 1999
Hi Matt,
the following code works perfectly for me ...
import httplib
h=httplib.HTTP("www.weihenstephan.org")
h.putrequest('GET', '/~petestoe/index.html')
h.putheader('Accept', 'text/html')
h.putheader('Accept', 'text/plain')
h.endheaders()
errcode, errmsg, headers = h.getreply()
print errcode # Should be 200
f = h.getfile()
data = f.read() # Get the raw HTML
f.close()
so it seems to me that your problem is at some other place of your code.
Greetings from Erding/Bavaria/Germany/Europe/World
Peter
"Matt Mencel
>
> When I try and run this code snippet I get this error in the f.read line.
>
> <<ERROR>>
> -1
> Traceback (innermost last):
> File "net.py", line 10, in ?
> data = f.read() # Get the raw HTML
> TypeError: not enough arguments
>
> <<CODE SNIPPET>>
> import httplib
> h=httplib.HTTP(www.somewebsite.com)
> h.putrequest('GET', '/somepage.html')
> h.putheader('Accept', 'text/html')
> h.putheader('Accept', 'text/plain')
> h.endheaders()
> errcode, errmsg, headers = h.getreply()
> print errcode # Should be 200
> f = h.getfile()
> data = f.read() # Get the raw HTML
> f.close()
--
---------------------------------------------------------------------------
Dr. Peter Stoehr --- Teisenbergweg 6 --- 85435 Erding --- 08122/47232
http://www.weihenstephan.org/home/ak/support/team/jpg/peter.jpg
---------------------------------------------------------------------------
I'm the terror that flaps through the night
More information about the Python-list
mailing list