-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
proxy_tool.py
146 lines (112 loc) · 4.17 KB
/
proxy_tool.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import requests
from rich import print
import threading
import time
working_proxies = []
def check(url, protocol, proxy):
global working_proxies
try:
response = requests.get(url, proxies={protocol:proxy}, timeout=2)
if response.status_code == 200:
print(f"Proxy {proxy} works! [{len(working_proxies)+1}]")
working_proxies.append(proxy)
else:
print(f"Proxy {proxy} failed")
except requests.RequestException as e:
pass
def proxy_checker(proxies, url="https://www.wired.com/review/klipsch-flexus-core-200/"):
proxies = proxies.text.split("\r\n")
if url.startswith("https"):
protocol = "https"
else:
protocol = "http"
proxies.pop()
i = 0
for proxy in proxies:
threading.Thread(target=check, args=(url, protocol, proxy)).start()
i += 1
if i == 20:
time.sleep(1.5)
i = 0
return working_proxies
def proxy_checker_(proxies, url="https://www.wired.com/review/klipsch-flexus-core-200/"):
proxies = proxies.split("\r\n")
if url.startswith("https"):
protocol = "https"
else:
protocol = "http"
proxies.pop()
i = 0
for proxy in proxies:
threading.Thread(target=check, args=(url, protocol, proxy)).start()
i += 1
if i == 20:
time.sleep(1.5)
i = 0
return working_proxies
def get_proxy():
global working_proxies
try:
f = open("found_proxies_http")
f2 = open("found_proxies_https")
res = f.read()
res2 = f2.read()
HTTP = proxy_checker_(res, "https://www.wired.com/review/klipsch-flexus-core-200/")
working_proxies = []
HTTPS = proxy_checker(res2)
print(f"[green]Total Number Of HTTP PROXIES FOUND : {len(HTTP)} [/green]")
print(f"[green]Total Number Of HTTPS PROXIES FOUND : {len(HTTPS)} [/green]")
f2.close()
f.close()
f = open("found_proxies_http", "w")
f2 = open("found_proxies_https", "w")
f.write("\n".join(HTTP))
f2.write("\n".join(HTTPS))
f.close()
f2.close()
except:
print("[red] [-] Failed, Maybe Because Already Didn't Have A proxyList To Refresh[/red]")
def gen_new():
global working_proxies
print("We are generating a new proxy list so it would take time... \[this happens when you are using old proxylist/have none]")
res = requests.get("https://api.proxyscrape.com/v2/?request=displayproxies&protocol=http&timeout=10000&country=all&ssl=all&anonymity=all")
res2= requests.get("https://api.proxyscrape.com/v2/?request=displayproxies&protocol=http&timeout=10000&country=all&ssl=all&anonymity=all")
HTTP = proxy_checker(res, "http://www.wired.com/review/klipsch-flexus-core-200/")
working_proxies = []
HTTPS = proxy_checker(res2)
print(f"[green]Total Number Of HTTP PROXIES FOUND : {len(HTTP)} [/green]")
print(f"[green]Total Number Of HTTPS PROXIES FOUND : {len(HTTPS)} [/green]")
f = open("found_proxies_http", "w")
f2 = open("found_proxies_https", "w")
f.write("\n".join(HTTP))
f2.write("\n".join(HTTPS))
f.close()
f2.close()
print("[blue] This Tool Belonging To OpenCrawler Project Can \nHelp With Generating And Checking HTTP And HTTPS Proxy List![/blue]")
print("")
print("""[blue]
\t [1] - Refresh The ProxyList, Remove Proxies Which Doesn't Work.
\t [2] - Renew The ProxyList, Autogenerate A New ProxyList.
\t [3] - Show Count of the Proxies HTTP And HTTPS.
[/blue]""")
t = input("[1,2,3] > ")
if t == "1":
get_proxy()
elif t == "2":
gen_new()
elif t == "3":
try:
f = open("found_proxies_http")
f2 = open("found_proxies_https")
res = f.read()
res2 = f2.read()
a = len(res.split('\r\n'))
b = len(res2.split('\r\n'))
print(f"[green]Total Number Of HTTP PROXIES FOUND : {a} [/green]")
print(f"[green]Total Number Of HTTPS PROXIES FOUND : {b} [/green]")
f2.close()
f.close()
except:
print("[red] [-] Failed, Maybe Because Already Didn't Have A proxyList[/red]")
else:
print("[red] [-] Unknown Command[/red]")