Michael <mo*****@mlug.missouri.edu> writes:
How do you change the user agent reported by urllib? I need to access
a resource that rejects anything but IE.
Here's how I do it in urllib2:
req = urllib2.Request(url, None, {'User-agent': userAgent})
fp = urllib2.urlopen(req)
Beware, some earlier versions of Python had bugs in the urllib*
libraries where it may override your setting of user agent or other
HTTP headers. This works fine for me in Python 2.3.3.