httplib\urllib attributes problem

Jordan Krushen jordan at krushen.com
Mon Jul 21 09:45:19 CEST 2003


On Sun, 20 Jul 2003 21:28:54 +0200, Bobbie <lorenb2 at bezeqint.net> wrote:

> The problem with urllib2 is that a "User-agent: Python-urllib/2.0a1" is, 
> again, sent
> by default. in case I setup a "User-Agent" attribute of my own it just, 
> again, sends
> them both. Note the lower-case 'a' letter in the former user-agent
> automatically sent by the library.  I can't even overrun it because of 
> that.
>
> I'll be happy for any kind of help, suggestion,...

At least for this one, here's the relevant code from urllib2.py:

class OpenerDirector:
    def __init__(self):
        server_version = "Python-urllib/%s" % __version__
        self.addheaders = [('User-agent', server_version)]

You should be able to override your opener's addheaders attribute 
(untested):

opener.addheaders = None

J.




More information about the Python-list mailing list