urllib - changing the user agent

John J. Lee jjl at pobox.com
Fri Jan 9 15:16:54 EST 2004


Terry Carroll <carroll at tjc.com> writes:

> On 9 Jan 2004 05:09:41 -0800, michael at foord.net (Fuzzyman) wrote:
> 
>  [ wants to change the user-agent in HTTP request from urllib ]
> 
> Fuzzy --
> 
> I take the easy way out, and use urllib2, instead:
[...]
>     req = urllib2.Request(url, None, req_headers)

or again, you can set .addheaders on OpenerDirector (which will cause
those headers to be added to all requests).


John



More information about the Python-list mailing list