Skip to content

Instantly share code, notes, and snippets.

@aragaer
Created December 23, 2011 10:26
Show Gist options
  • Select an option

  • Save aragaer/1513816 to your computer and use it in GitHub Desktop.

Select an option

Save aragaer/1513816 to your computer and use it in GitHub Desktop.
proxy = None
proxydict = urllib2.ProxyHandler().proxies
for type in ["https", "http", "socks"]:
if type not in proxydict:
continue
proxyline = proxydict[type]
schemalen = length(type + 3) # "<schema>://"
if proxyline[:schemalen] == "%s://" % type
proxyline = proxyline[schemalen:]
proxAddr, proxPort = proxyline.split(":")
proxPort = int(proxPort.rstrip("/"))
proxy = (proxAddr, proxPort)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment