问题
I am using the following code found on post, How to specify an authenticated proxy for a python http connection?
import urllib2
def get_proxy_opener(proxyurl, proxyuser, proxypass, proxyscheme="http"):
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, proxyurl, proxyuser, proxypass)
proxy_handler = urllib2.ProxyHandler({proxyscheme: proxyurl})
proxy_auth_handler = urllib2.ProxyBasicAuthHandler(password_mgr)
return urllib2.build_opener(proxy_handler, proxy_auth_handler)
if __name__ == "__main__":
import sys
if len(sys.argv) > 4:
url_opener = get_proxy_opener(*sys.argv[1:4])
for url in sys.argv[4:]:
print url_opener.open(url).headers
else:
print "Usage:", sys.argv[0], "proxy user pass fetchurls..."
I am using the proxy ip as specified in my wpad.dat file for argv[1]. (# for confidentiality)
return "PROXY 138.84.###.###:####";
I am using my username and password for argval[2] and [3]. When I use http://google.com it spits out the appropriate header information. When I use http://shipcsx.com/pub_sx_mainpagepublic_jct/sx.shipcsxpublic/Main it shows: HTTP Error 407: Proxy Authentication Required.
回答1:
This may not be a question for StackExchange. You may need some visibility into your proxy server to troubleshoot properly. With no other information, I'll take an offhand guess that the Google domain (or part of it) is configured as a trusted site at the proxy. This allows a request to bypass proxy authentication entirely.
来源:https://stackoverflow.com/questions/29826730/why-am-i-getting-this-error-http-error-407-proxy-authentication-required