How to use HTTP proxies in Python2?

1. 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
----------------------------------------------------
 
 
  • 104 Users Found This Useful
Was this answer helpful?

Related Articles

Proxy Manager Guide

1.    Go to http://squidproxies.com/proxymanager/ProxyManager-v1.zip     2.    Save File,...

How to use a proxy in an Ipad/Iphone?

On the screen, click on Settings. Click on Wi-Fi and you will see list of networks on the...

How to use a proxy in Chrome?

Click the Chrome menu on the  browser toolbar. Select Settings. Scroll down. Click "Show...

How to test proxies in Linux command line interface?

You can easily use our proxies within the Linux CLI using any command-line tool you love. Below...

How to use a proxy in Safari?

Open Safari, then go to Preferences. In the Advanced tab, click on Proxies then Change Settings....

Powered by WHMCompleteSolution