httplib problems.
Sammy Mannaert
nstalkie at tvd.be
Wed Apr 11 12:57:21 EDT 2001
hi,
i'm trying to use httplib to fetch a file
automatically. it's basically just the
example from the 2.0 httplib GET example.
it works for all urls except for
http://www.deathinjune.net/html/news/news.htm
does anyone know why it won't work for this
url ? is there an easy way to fix it ?
i tried surfinf to the url in netscape and
lynx. both worked fine.
sammy
--- program follows ---
#! /usr/bin/env python
import httplib
def fetch(domain, path):
h = httplib.HTTP(domain)
h.putrequest('GET', path)
h.putheader('Accept', 'text/html')
h.putheader('Accept', 'text/plain')
h.endheaders()
errcode, errmsg, headers = h.getreply()
print errcode
f = h.getfile()
data = f.read()
f.close()
print len(data)
def main():
fetch('www.brainwashed.com', '/c93/news1.html')
fetch('www.deathinjune.net', '/html/news/news.htm')
main()
--- program end ---
More information about the Python-list
mailing list