egmanoj at yahoo.com wrote: | Hello, | I am trying to use the Python(1.5) urllib module's urlopen method to | retrieve an xml file from a website. The request has to go through | our LAN's proxy server and this needs a username and password. | | How can I automatically supply the username and password while using | this from a script? [There is no problem while using urlopen from the | IDLE; the prompt comes up and I just have to type in the username and | password] For a proxy authorization, you need to send an additional "Proxy-authorization" header with the base64 "encryption" of your username and password. I don't think you can do that with urllib, but you can use the httplib module instead: import binascii cookie = binascii.b2a_base64("username:password") ... h.putheader('Proxy-authorization', 'Basic %s' % cookie) -- Dick Streefland //// TASKING Software BV dick.streefland at tasking.com (@ @) http://www.tasking.com --------------------------------oOO--(_)--OOo---------------------------
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4