User-Agent, version and other mysteries
Stefan Faltz
stefanfaltz at web.de
Tue Apr 2 09:22:28 EST 2002
I try to change the "User-Agent" header, i tried it first by something
like
urllib.FancyURLopener.version = "Whatever Agent you like"
that didn't work, what a surprise
then i ripped some code, and i think it is reasonable
class AppURLopener(urllib.FancyURLopener):
def __init__(self, *args):
apply(urllib.FancyURLopener.__init__, (self,) + args)
self.version = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.0; T312461; Q312461)"
urllib._urlopener = AppURLopener
agent=urllib.FancyURLopener()
or
agent=AppURLopener()
or
agent=urllib._urlopener
even
agent=urllib.AppURLopener()
and now i am lost, changing the code upside/down
i was thinking of doing a
urllib.addheader('User-Agent','whateveragent')
but that can't be the right solution, that is just tooo, i don't like
that idea
or changing the Version string right in the urllib, but that is even
worse
maybe anyone has solved the problem allready, i was looking for any
readme or tutorial, but wasn't able to find one
More information about the Python-list
mailing list