-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxyChecker.py
57 lines (45 loc) · 1.92 KB
/
proxyChecker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from proxy_checker import ProxyChecker
import concurrent.futures
import os
# Provide the full path to the proxy file
proxies_file = "C:/Users/aymen/Desktop/foundings/proxies/23 - https proxy - Pastehook.txt"
# Function to read proxies from file
def read_proxies(file_path):
proxies = []
with open(file_path, "r") as file:
for line in file:
proxy = line.strip()
if proxy: # Check if the line is not empty
proxies.append(proxy)
return proxies
# Function to check proxy quality and reliability
def check_proxy(proxy):
checker = ProxyChecker()
result = checker.check_proxy(proxy)
print(f"Checking proxy: {proxy}")
print("Full result dictionary:", result) # Print the full result dictionary for debugging
if result and result["anonymity"] == "High":
response_time = result.get("response_time", "N/A")
print(f"Proxy {proxy} is working. Anonymity level: {result['anonymity']}, Response time: {response_time} ms")
if response_time != "N/A" and response_time < 1000:
return proxy
else:
print(f"Proxy {proxy} does not meet quality criteria.")
return None
# Read proxies from file
proxy_list = read_proxies(proxies_file)
# Check proxies using multiple threads for faster processing
verified_proxies = []
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
for proxy in executor.map(check_proxy, proxy_list):
if proxy:
verified_proxies.append(proxy)
# Create the directory if it doesn't exist
output_directory = os.path.expanduser("~/Desktop/verified_proxies")
os.makedirs(output_directory, exist_ok=True)
# Write verified proxies to a new text file
output_file = os.path.join(output_directory, "verified_proxies.txt")
with open(output_file, "w") as file:
for proxy in verified_proxies:
file.write(proxy + "\n")
print(f"Verified proxies saved to {output_file}")