Last active
November 6, 2025 06:26
-
-
Save makesomelayouts/1fcd46eb5a3df28aa0f6a370a88780d6 to your computer and use it in GitHub Desktop.
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 requests | |
| with open('proxies.txt') as f: | |
| proxies = f.read().split('\n') | |
| """ or! | |
| proxies = f.readlines() | |
| proxies = [proxy.strip() for proxy in proxies] | |
| """ | |
| working_proxies = [] | |
| print(proxies) | |
| for proxy in proxies: | |
| try: | |
| print(f'Using the proxy: {proxy}') | |
| r = requests.get(url='https://books.toscrape.com/', proxies={'https': proxy}, timeout=1) | |
| if r.status_code == 200: | |
| print('Proxy is working') | |
| working_proxies.append(proxy) | |
| else: | |
| print(r.status_code) | |
| except Exception as e: | |
| print(e) | |
| with open('working_proxies.txt', 'w') as f: | |
| for proxy in working_proxies: | |
| f.write(proxy + '\n') |
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
| if __name__ == '__main__': | |
| import requests, threading, queue | |
| q = queue.Queue() | |
| valid_proxies = [] | |
| with open('proxies.txt', 'r') as f: | |
| proxies = f.read().split('\n') | |
| for proxy in proxies: | |
| q.put(proxy) | |
| def check_proxies(): | |
| global q | |
| while not q.empty(): | |
| proxy = q.get() | |
| try: | |
| response = requests.get('http://ipinfo.io/json', proxies={'http': proxy, 'https': proxy}) | |
| except: | |
| continue | |
| if response.status_code == 200: | |
| print(proxy) | |
| for _ in range(10): | |
| threading.Thread(target=check_proxies).start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment