| 29 | |
| 30 | |
| 31 | class proxy: |
| 32 | def update(self): |
| 33 | while True: |
| 34 | data = "" |
| 35 | urls = [ |
| 36 | "https://api.proxyscrape.com/?request=getproxies&proxytype=socks4&timeout=10000&ssl=yes" |
| 37 | ] |
| 38 | for url in urls: |
| 39 | data += requests.get(url).text |
| 40 | self.splited += data.split("\r\n") # scraping and splitting proxies |
| 41 | time.sleep(600) |
| 42 | |
| 43 | def get_proxy(self): |
| 44 | random1 = random.choice(self.splited) # choose a random proxie |
| 45 | return random1 |
| 46 | |
| 47 | def FormatProxy(self): |
| 48 | proxyOutput = {"https": "socks4://" + self.get_proxy()} |
| 49 | return proxyOutput |
| 50 | |
| 51 | def __init__(self): |
| 52 | self.splited = [] |
| 53 | threading.Thread(target=self.update).start() |
| 54 | time.sleep(3) |
| 55 | |
| 56 | |
| 57 | proxy1 = proxy() |