-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
53 lines (47 loc) · 1.52 KB
/
main.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
import re
import threading
import requests
class scan(threading.Thread):
def __init__(self, thread):
threading.Thread.__init__(self)
self.thread = thread
def check_proxy(self, proxy):
check_url = 'https://www.baidu.com'
proxies = {
'https': fr'http://{proxy}'
}
try:
requests.get(url=check_url, proxies=proxies, timeout=3)
print('success: ' + proxy)
except requests.exceptions.ConnectionError:
print('error')
except requests.exceptions.ReadTimeout:
print('timeout')
except KeyboardInterrupt:
print('用户退出')
exit()
except requests.exceptions.InvalidSchema:
exit()
def run(self):
for k in proxy_list:
self.check_proxy(k)
if __name__ == '__main__':
print('start success')
proxy_list = []
for i in range(1, 5):
url = 'https://ip.jiangxianli.com/?page=%s' % str(i)
r = requests.get(url)
pattern = re.compile(r'href="//(((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d?\d:.*)">)')
m = pattern.findall(r.text)
for j in range(0, len(m)):
a = (m[j])[0].replace('">', '')
proxy_list.append(a)
print(proxy_list)
threads = []
thread_count = 10
for i in range(thread_count):
t = scan(i)
t.start()
threads.append(t)
for thread in threads:
thread.join()