Knowledgebase

  • Home
  • /
  • Knowledgebase

Knowledgebase

Please Login or Register
You are here: Portal Home > Knowledgebase > Proxy Tutorials > How to use HTTP proxies in Python2?

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
----------------------------------------------------
 
 


Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read

Powered by WHMCompleteSolution

© Copyright SquidProxies.com. All right reserved.