BUG URLLIB2
John Hunter
jdhunter at ace.bsd.uchicago.edu
Wed Nov 20 01:00:06 EST 2002
>>>>> "bart" == bart <e_viola at libero.it> writes:
bart> Thanks to all them that helped me swiftly!!!
bart> How can I change User-Agent field presents inside "urllib2"?
bart> I find two variables that (I think) define user agent in
bart> "urllib2" library: "__name__" and "__version__".
I think this will help
import urllib
class AppURLopener(urllib.FancyURLopener):
def __init__(self, *args):
self.version = "MSIE/5.0"
apply(urllib.FancyURLopener.__init__, (self,) + args)
urllib._urlopener = AppURLopener()
url = 'http://www.google.it/search'
s = urllib._urlopener.open(url).read()
print s
And once again, please limit your cross-posting (posting the same
question to many groups).
John Hunter
More information about the Python-list
mailing list