-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_proxy.py
31 lines (28 loc) · 1011 Bytes
/
get_proxy.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
# - coding: utf-8 -
import traceback
import socket
import socks
import requests
proxy_count = 100
proxies = requests.get("https://proxy.ishield.cn/?types=0&count={}".format(proxy_count)).json()
with open("proxy.txt", "w") as f:
for proxy in proxies:
try:
HOST = '128.14.230.246'
PORT = 30000
host, port, _ = proxy
#socks.set_default_proxy(socks.HTTP, host, port)
#with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
# s.connect((HOST, PORT))
# s.close()
proxies = {
'http': 'http://{}:{}'.format(host, port),
}
r = requests.head("http://sgz-login.fingerfunol.com:30006", timeout=2, proxies=proxies)
if r.status_code in [200, 404]:
f.write("{} {}".format(host, port))
f.write("\n")
except:
print(traceback.format_exc())
print("proxy not supported")
continue