Pass proxy authentication using python's urllib3.
proxy_test.py
#Set user ID and password separated by colon userid:password
PROXY_BASIC_AUTH = "userid:password"
#Proxy URL, port
PROXY_URL = "http://proxy.net:8080"
#URL to connect to
REQUEST_URL = "https://www.djangoproject.com/"
if __name__ == '__main__':
headers = urllib3.util.make_headers(proxy_basic_auth=PROXY_BASIC_AUTH)
http = urllib3.ProxyManager(proxy_url=PROXY_URL,
proxy_headers=headers, cert_reqs='CERT_REQUIRED', ca_certs=certifi.where())
r = http.request("GET", REQUEST_URL)
#output
print(r.data, r.status, )
Recommended Posts