Skip to content

Instantly share code, notes, and snippets.

@miklevin
Created August 11, 2017 14:42
Show Gist options
  • Save miklevin/2e76b75398b68ede5a17b8d4783ab951 to your computer and use it in GitHub Desktop.
Save miklevin/2e76b75398b68ede5a17b8d4783ab951 to your computer and use it in GitHub Desktop.
Takes a text file of web proxies and makes sure you round-robin between C-blocks
proxies = []
with open('goodproxies.txt', 'r') as f:
for line in f:
proxies.append(line.strip())
block_dict = dict()
blocks = set()
staggered = []
for proxy in proxies:
block = '.'.join(proxy.split('.')[:3])
block_dict[proxy] = block
blocks.add(block)
staggered = []
while proxies:
for block in blocks:
for index, test_next in enumerate(proxies):
next_block = '.'.join(test_next.split('.')[:3])
if block == next_block:
staggered.append(test_next)
del proxies[index]
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment