0

How use Secure Web Proxy, like documented this (443, HTTPS) with urllib2? For example, i'm trying

opener = urllib2.build_opener(urllib2.HTTPHandler, urllib2.HTTPSHandler,urllib2.ProxyHandler({"https": 'https://some_proxy.com:443'}))
urllib2.install_opener(opener)

but getting timeout. The proxy is works in others applications, such on browsers via PAC file.

P.S. Proxy with urllib2 not duplicate question, because doesn't have info about Secure Web Proxy.

ilw
  • 2,499
  • 5
  • 30
  • 54

1 Answers1

0

You can try using the urllib3 library

from urllib3 import ProxyManager

http = ProxyManager("https://some.proxy.com:8080/")
response = http.request('GET', 'https://stackoverflow.com/')

if you want to send headers as well to the proxy then

from urllib3 import ProxyManager, make_headers

default_headers = make_headers(proxy_basic_auth='username:password')
http = ProxyManager("https://some.proxy.com:8080/", headers=default_headers)
response = http.request('GET', 'https://stackoverflow.com/')