I'm behind a corporate proxy (Isa Server).
When using urllib2 I can connect through the proxy to the internet without any problem, but when using the requests library I can't.
Here is my urllib2 code:
proxy = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
page = urllib2.urlopen('http://www.google.com')
print page.getcode()
This prints '200' and works fine
However when doing the same with requests I get a 407 code and doesn't work.
proxy_dict = {
'http': 'http://10.20.23.5:8080',
'https': 'ftp://10.20.23.5:8080',
'ftp': 'https://10.20.23.5:8080'
}
page = requests.get('http://www.google.com', proxies=proxy_dict)
print page.status_code
print page.reason
This prints '407' and the reason: 'Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied. )'
Even if I pass to requests the proxies from urllib2 doesn't work either:
page = requests.get('http://http://www.google.com', proxies=urllib2.getproxies())
Urllib2 is doing something that requests is not.
Any help?