Advertisement
Guest User

Untitled

a guest
Feb 6th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. from threading import Thread
  2.  
  3. import requests
  4.  
  5.  
  6. with open('working-proxies-history.txt') as f:
  7.     proxy_list = [f'http://{proxy}' for proxy in f.read().split()]
  8.  
  9.  
  10. def fetch(proxy: str):
  11.     try:
  12.         requests.get('http://icanhazip.com', proxies={
  13.             'http': proxy,
  14.             'https': proxy
  15.         }, timeout=6).text
  16.     except:
  17.         pass
  18.     else:
  19.         results.append(True)
  20.  
  21.  
  22. step = 400
  23.  
  24. count = 0
  25. results = []
  26.  
  27. for i in range(0, len(proxy_list), step):
  28.     threads = []
  29.     for proxy in proxy_list[i:i + step]:
  30.         thread = Thread(target=fetch, args=(proxy,))
  31.         thread.start()
  32.         threads.append(thread)
  33.  
  34.     for thread in threads:
  35.         thread.join()
  36.  
  37.     count += results.count(True)
  38.  
  39. print(count)
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement