-
Notifications
You must be signed in to change notification settings - Fork 1
/
getproxy.py
161 lines (155 loc) · 8 KB
/
getproxy.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import json
import time
import datetime
import requests
import re
res1 = dict()
res2 = list()
class Downloadproxies():
def __init__(self) -> None:
self.api = {
'socks4':[
"https://api.proxyscrape.com/?request=displayproxies&proxytype=socks4&country=all",
"https://www.proxy-list.download/api/v1/get?type=socks4",
"https://www.proxyscan.io/download?type=socks4",
"https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks4.txt",
'https://raw.githubusercontent.com/jetkai/proxy-list/main/online-proxies/txt/proxies-socks4.txt',
"https://api.openproxylist.xyz/socks4.txt",
"https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/socks4.txt",
"https://www.freeproxychecker.com/result/socks4_proxies.txt",
"https://raw.githubusercontent.com/roosterkid/openproxylist/main/SOCKS4_RAW.txt",
'https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/socks4.txt',
'https://raw.githubusercontent.com/mmpx12/proxy-list/master/socks4.txt',
'https://raw.githubusercontent.com/rdavydov/proxy-list/main/proxies/socks4.txt',
'https://raw.githubusercontent.com/RX4096/proxy-list/main/online/socks4.txt',
'https://raw.githubusercontent.com/UptimerBot/proxy-list/main/proxies/socks4.txt',
'https://openproxy.space/list/socks4'],
'socks5': [
"https://api.proxyscrape.com/v2/?request=getproxies&protocol=socks5&timeout=10000&country=all&simplified=true",
"https://www.proxy-list.download/api/v1/get?type=socks5",
"https://www.proxyscan.io/download?type=socks5",
"https://raw.githubusercontent.com/TheSpeedX/PROXY-List/master/socks5.txt",
"https://raw.githubusercontent.com/hookzof/socks5_list/master/proxy.txt",
"https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/socks5.txt",
"https://raw.githubusercontent.com/jetkai/proxy-list/main/online-proxies/txt/proxies-socks5.txt",
"https://api.openproxylist.xyz/socks5.txt",
"https://www.freeproxychecker.com/result/socks5_proxies.txt",
"https://raw.githubusercontent.com/roosterkid/openproxylist/main/SOCKS5_RAW.txt",
'https://raw.githubusercontent.com/monosans/proxy-list/main/proxies/socks5.txt',
'https://raw.githubusercontent.com/mmpx12/proxy-list/master/socks5.txt',
'https://raw.githubusercontent.com/rdavydov/proxy-list/main/proxies/socks5.txt',
'https://raw.githubusercontent.com/RX4096/proxy-list/main/online/socks5.txt',
'https://raw.githubusercontent.com/manuGMG/proxy-365/main/SOCKS5.txt',
'https://raw.githubusercontent.com/UptimerBot/proxy-list/main/proxies/socks5.txt',
'https://openproxy.space/list/socks5',
'https://spys.me/socks.txt'],
'http': [
"https://api.proxyscrape.com/?request=displayproxies&proxytype=http",
"https://www.proxy-list.download/api/v1/get?type=http",
"https://www.proxyscan.io/download?type=http",
"http://spys.me/proxy.txt",
"https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/http.txt",
"https://api.openproxylist.xyz/http.txt",
"https://raw.githubusercontent.com/shiftytr/proxy-list/master/proxy.txt",
"http://alexa.lr2b.com/proxylist.txt",
"http://rootjazz.com/proxies/proxies.txt",
"https://www.freeproxychecker.com/result/http_proxies.txt",
r"http://proxysearcher.sourceforge.net/Proxy%20List.php?type=http",
"https://raw.githubusercontent.com/jetkai/proxy-list/main/online-proxies/txt/proxies-http.txt",
"https://raw.githubusercontent.com/clarketm/proxy-list/master/proxy-list-raw.txt",
"https://raw.githubusercontent.com/sunny9577/proxy-scraper/master/proxies.txt",
"https://raw.githubusercontent.com/opsxcq/proxy-list/master/list.txt"
"https://proxy-spider.com/api/proxies.example.txt",
"https://multiproxy.org/txt_all/proxy.txt",
"https://raw.githubusercontent.com/roosterkid/openproxylist/main/HTTPS_RAW.txt",
"https://raw.githubusercontent.com/UserR3X/proxy-list/main/online/http.txt",
"https://raw.githubusercontent.com/UserR3X/proxy-list/main/online/https.txt",
'https://raw.githubusercontent.com/UptimerBot/proxy-list/main/proxies/http.txt',
'https://openproxy.space/list/http'
]}
self.proxy_dict = {'socks4':'','socks5':'','http':''}
pass
def get(self,type):
self.proxy_list = []
for api in self.api[type]:
try:
self.r = requests.get(api,timeout=5)
if self.r.status_code == requests.codes.ok :
self.proxy_list += re.findall('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{2,5}',self.r.text)
self.proxy_dict[type] = list(set(self.proxy_list))
except:
pass
if type == 'socks4':
try:
r = requests.get("https://www.socks-proxy.net/",timeout=5)
self.part = str(r.text)
self.part = self.part.split("<tbody>")
self.part = self.part[1].split("</tbody>")
self.part = self.part[0].split("<tr><td>")
self.proxies = ""
for proxy in self.part:
proxy = proxy.split("</td><td>")
try:
if self.proxies != '':
self.proxies=self.proxies + proxy[0] + ":" + proxy[1] + "\n"
except:
pass
if self.proxies != '':
self.proxy_list += self.proxies.split('\n')
self.proxy_list = list(set(self.proxy_list))
self.proxy_dict[type] = list(set(self.proxy_list))
except:
pass
print('> Get {} proxies done'.format(type))
def get_extra(self):
self.yesterday = datetime.date.today() + datetime.timedelta(-1)
self.r = requests.get('https://checkerproxy.net/api/archive/{}-{}-{}'.format(self.yesterday.year,self.yesterday.month,self.yesterday.day))
if self.r.text != '[]':
self.json_result = json.loads(self.r.text)
else:
del self.r
self.t_d_b_yesterday = datetime.date.today() + datetime.timedelta(-2)
self.r = requests.get('https://checkerproxy.net/api/archive/{}-{}-{}'.format(self.t_d_b_yesterday.year,self.t_d_b_yesterday.month,self.yesterdat_d_b_yesterday.day))
self.json_result = json.loads(self.r.text)
for i in self.json_result:
if i['type'] == 1 and i['ip'] != '172.23.0.1':
self.proxy_dict['http'].append(i['addr'])
if i['type'] == 2 and i['ip'] != '172.23.0.1':
self.proxy_dict['http'].append(i['addr'])
if i['type'] == 4:
self.proxy_dict['socks5'].append(i['addr'])
print('> Get extra proxies done')
def get_all(self):
self.get('socks4')
self.get('socks5')
self.get('http')
self.get_extra()
def save(self,typ):
global res1,res2
tmp = list()
self.out_file = r"C:\Python310\files\proxy.txt"
for i in self.proxy_dict[typ]:
if '#' in i or i == '\n':
self.proxy_dict[typ].remove(i)
else:
tmp.append(i)
res2.append(i)
if typ == 'socks4':
res1.update({'socks4':tmp})
elif typ == 'socks5':
res1.update({'socks5':tmp})
elif typ == 'http':
res1.update({'https':tmp})
f = open(self.out_file,'w')
f.write(str(res1)+'\n')
f.write(str(res2))
f.close()
print("> Have already downloaded proxies list as "+self.out_file)
def save_all(self):
self.save('socks4')
self.save('socks5')
self.save('http')
if __name__ == '__main__':
d = Downloadproxies()
d.get_all()
d.save_all()