urllib - changing the user agent

Fuzzyman michael at foord.net
Tue Jan 13 03:53:03 EST 2004


Thanks to all who posted help.
I think theres more than enough to get me through this - when I get a
chance I'll sit and have a play. I'm sure I'll have more
questions.......

Thanks

Fuzzy

jjl at pobox.com (John J. Lee) wrote in message news:<87eku7y9zj.fsf at pobox.com>...
> Samuel Walters <swalters_usenet at yahoo.com> writes:
> 
> > |Thus Spake John J. Lee On the now historical date of Fri, 09 Jan 2004
> > 20:16:54 +0000|
> >  
> > > or again, you can set .addheaders on OpenerDirector (which will cause
> > > those headers to be added to all requests).
> 
> (just to clarify, I meant an OpenerDirector instance, not the class
> itself)
> 
> 
> > This, however, does not stop the original User-agent header to be sent,
> > and google still filters out the request.  Instead, it just causes a
> > second user-agent to be sent.
> 
> No, it does stop them being sent.  Perhaps you mutated the base class
> .addheaders by mistake (using .append(("User-agent", "blah")), for
> example)?  Don't do that!  Mutating class attributes is a bad idea.
> 
> 
> > Here is the very bad code I used to solve this problem.  There are better
> > ways, I assure you, but it should point you in the right direction.  You
> [...]
> 
> No need to assure me of *that* <wink>.  You can call a base class
> constructor directly, you know.  And clobbering the base class'
> constructor is another very bad idea.
> 
> 
> John



More information about the Python-list mailing list