Wednesday, August 17, 2011

Python urllib proxies

It is possible to open a url via a proxy server using urllib as shown in the following code.
Here is the documentation.
Here is a list of proxies. To check your IP you can use this site.

import urllib
import re

httpProxy =  "http://85.172.205.91.static.giga-dns.com:3128"
webSite = "http://whatismyipaddress.com/"

if False:
    # no proxy.
    txt = urllib.urlopen(webSite).read()

if True:
    # with proxy.
    proxies = {'http':httpProxy}
    txt = urllib.urlopen(webSite, proxies=proxies).read()
    
IPreg = re.compile('

No comments:

Post a Comment

Continuously monitor GPU usage

 For nvidia GPUs do the follwing: nvidia-smi -l 1