urllib.open('http://www.redherring.com/')
Greg Jorgensen
gregj at pobox.com
Thu Feb 8 04:53:00 EST 2001
In article <3A825A68.B1023097 at intertrader.com>,
Andrew Cooke <andrew at intertrader.com> wrote:
>
> Maybe they're checking an HTTP header line and only responding to
known
> browsers?
I tried sending some standard headers, but it still hung and then came
back with "connection reset by peer."
``````````````````````````````````
import httplib
h = httplib.HTTP("redherring.com")
h.connect()
h.putrequest("GET","/")
h.putheader("Accept", "text/html")
h.putheader("Accept", "text/plain")
h.putheader("User-Agent", "Mozilla/4.08 [en] (Windows NT 5.0)")
h.putheader("Accept", "image/gif, image/jpeg")
h.putheader("Accept-Language", "en")
h.putheader("Accept-Charset", "iso-8859-1,*,utf-8")
h.endheaders()
errcode, errmsg, headers = h.getreply()
f = h.getfile()
s = f.read()
f.close()
print h
print "content length: %d" % len(s)
``````````````````````````````````````````
--
Greg Jorgensen
Portland, Oregon, USA
gregj at pobox.com
Sent via Deja.com
http://www.deja.com/
More information about the Python-list
mailing list