How to use HTTP/HTTPS proxies in Python2?

1. You must create a file called testproxy.py, containing:
 
Import urllib2
 
proxy_handler = urllib2.ProxyHandler({"HTTP":"1.2.3.4:8800", "HTTPS":"1.2.3.4:8800"})
opener = urllib2.build_opener(proxy_handler)
urllib2.install_opener(opener)
 
HTML = urllib2.urlopen("http://www.google.com").read()
print HTML
 
 
2. Run the script using:
 
python testproxy.py

Was this answer helpful?

 Print this Article

Also Read

How to Set Up Proxy on iPhone or iPad

Open your iPhone - iPad settings Tap Wi-Fi Select the info icon on the right side...

How to use Proxy-N-Vpn proxies with Google Chrome Browser

Google Chrome Browser is using your computer’s system proxy settings to connect to the Internet....

How to Set Up VPN (Virtual Private Network) Connection in Windows 10

  Windows 10 supports PPTP, L2TP/IPsec, SSTP, and IKEv2 connections without any third-party...

How To Set Up a VPN or a Proxy on SENuke

• A VPN works alongside SENuke so once the VPN is connected then SENuke will be using whatever IP...

How to use HTTP/HTTPS proxies on BlueStacks AppPlayer with ProxyCap

BlueStacks AppPlayer is an Android emulator for your Mac and PC. If you want to use BlueStacks...