954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Python's urllib2 and proxy authentication

Hi, I as a Python novice I throw myself at the mercy of experts in this forum. Could someone post a simple example of how to implement urllib2's proxy authentication. I've read all the references google returns as well as searched this site and cannot find an example that I can understand about how to do this.
I can do the simple proxy handler (below) as outlined on the Missing Manua l but still get 407 errors because I don't know how to do the authentication part.

proxy_support = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)


I'd be massively grateful for any help - I can't imagine I am alone in trying to understand this.

andrewtrench
Newbie Poster
18 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

You need to put

{"http" : "http://iptoproxy:port"}

inside the proxyhandler's argument

ultimatebuster
Posting Whiz in Training
250 posts since Mar 2010
Reputation Points: 24
Solved Threads: 69
 

Hi, thanks, but I have tried that and still get the following error

HTTPError: HTTP Error 407: Proxy Authentication Required
andrewtrench
Newbie Poster
18 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: