Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from concurrent.futures.thread import ThreadPoolExecutor
- import requests
- def verify_proxy(proxy, test_url='https://www.google.com'):
- host, port, *_ = proxy
- try:
- requests.get(test_url, proxies={
- 'http': f'socks5://{host}:{port}',
- 'https': f'socks5://{host}:{port}',
- })
- except BaseException as e:
- return False
- return True
- def gen_proxies(fp):
- with open(fp) as f:
- for line in f:
- if not line.strip():
- continue
- yield line.strip().split(':')
- if __name__ == '__main__':
- candidates = tuple(gen_proxies('socks5'))
- with ThreadPoolExecutor(max_workers=5) as executor:
- for candidate, working in zip(candidates, executor.map(verify_proxy, candidates)):
- if not working:
- continue
- print(f'{candidate} is usable')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement