Pass the authentication proxy through communication using python urllib3

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

Pass the authentication proxy through communication using python urllib3
WiringPi-SPI communication using Python
Authentication using tweepy-User authentication and application authentication (Python)
[SAM] Try using RDS Proxy with Lambda (Python) [user/pass, IAM authentication]
Extract the targz file using python
Try using the Python Cmd module
Addictive point when going through http proxy with basic authentication in python
Try using the Wunderlist API in Python
Try using the Kraken API in Python
Behind the flyer: Using Docker with Python
Learn the design pattern "Proxy" in Python
Pass the path of the imported python module
Socket communication using socketserver with python now
Tweet using the Twitter API in Python
[Python] [Windows] Serial communication in Python using DLL
Working with OpenStack using the Python SDK
Setting up Basic authentication using Python @Lambda
Reboot the router using Python, Selenium, PhantomJS
Academia Potter and the Mysterious Python Pass
python setup.py test the code using multiprocess
Setting up Digest authentication using Python @Lambda
Aggregate test results using the QualityForward Python library
vprof --I tried using the profiler for Python
[Python] Let's execute the module regularly using schedule
Try using the BitFlyer Ligntning API in Python
Python: Try using the UI on Pythonista 3 on iPad
Try using the Python web framework Tornado Part 1
Pass values between pages using Python 3.5 cgi module
I tried using the Datetime module by Python
Pre-process the index in Python using Solr's ScriptUpdateProcessor
Operate the schedule app using python from iphone
Sound the buzzer using python on Raspberry Pi 3!
Try using the collections module (ChainMap) of python3
Find the geometric mean of n! Using Python
Try using the Python web framework Tornado Part 2
Try using the DropBox Core API in Python
Run the Blue Prism process using Python (SOAP)
Approximate a Bezier curve through a specified point using the least squares method in Python