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

Related Articles

How to use a proxy in Chrome?

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

How to add my authorized IP?

To add your authorized IP, please go to : http://vip.squidproxies.com1. Login to the VIP control...

How to use HTTP proxies in PHP code?

  We support PHP code as long as the CURL library is enabled. 1. Create a file called...

How to use a proxy in Mac OS?

Choose Apple menu > System Preferences, then click Network. Choose the network service you...

How to use a proxy in Internet Explorer?

Go to Tools> Internet Options Click Connections > LAN Settings On Local Area Networn...

Powered by WHMCompleteSolution