script detection
Stefan Schwarzer
s.schwarzer at ndh.net
Mon Jan 28 12:53:27 EST 2002
cyclotron wrote:
> I get a page where it says something about that my login was
> successful (so I think the cookie part works) but it also says "We
> don't support scripts" in the html code.
> How can I fake the browser identification? I couldn't find useful
> information about it on the net.
The following code contains the headers which my Netscape browser sends:
url = 'http://www.python.org/'
host = urlparse.urlsplit(url)[1]
req = urllib2.Request(url)
req.add_header('Connection', 'Keep-Alive')
req.add_header('User-Agent', 'Mozilla/4.61 [en] (OS/2; U)')
req.add_header('Host', host)
req.add_header('Accept', 'image/gif, image/x-xbitmap, '
'image/jpeg, image/pjpeg, image/png, */*')
req.add_header('Accept-Encoding', 'gzip')
req.add_header('Accept-Language', 'de-DE,en')
req.add_header('Accept-Charset', 'iso-8859-1,*,utf-8')
response = urllib2.urlopen(req)
got = response.read()
response.close()
HTH
Stefan
More information about the Python-list
mailing list