Created
July 3, 2015 21:40
-
-
Save THEMVFFINMAN/46fc89b7d487f85edf62 to your computer and use it in GitHub Desktop.
Returns a random proxy paired with the proper port.
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
import mechanize, random | |
def random_line(afile): | |
line = next(afile) | |
for num, aline in enumerate(afile): | |
if random.randrange(num + 2): | |
continue | |
line = aline | |
return line.replace("\n", "") | |
def getProxy(): | |
browser = mechanize.Browser() | |
browser.set_handle_robots(False) | |
page = browser.open('http://rmccurdy.com/scripts/proxy/good.txt') | |
ipPort = random_line(page) | |
return {'http': ipPort} | |
getProxy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment