Created
December 23, 2011 10:26
-
-
Save aragaer/1513816 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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