persist proxy
This commit is contained in:
parent
9cf3f9a3f4
commit
82c6b57907
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python3
|
||||
import random
|
||||
import json
|
||||
import urllib.parse
|
||||
import re
|
||||
@ -172,16 +171,16 @@ class MainHandler(tornado.web.RequestHandler):
|
||||
if isinstance(proxy_list_orig, list):
|
||||
proxy_list = proxy_list_orig.copy()
|
||||
if isinstance(proxy_list, list):
|
||||
rand = random.SystemRandom()
|
||||
rand.shuffle(proxy_list)
|
||||
for proxy_temp in proxy_list:
|
||||
try:
|
||||
resp = requests.head(src, allow_redirects=True, proxies=proxy_temp.req, timeout=(0.1, 2.0))
|
||||
resp = requests.head(src, allow_redirects=True, proxies=proxy_temp.req, timeout=(1, 2))
|
||||
if resp is not None:
|
||||
src = resp.url
|
||||
except Exception as e:
|
||||
print(e)
|
||||
else:
|
||||
proxy_list.remove(proxy_temp)
|
||||
proxies[provider] = [proxy_temp] + proxy_list
|
||||
proxy = proxy_temp
|
||||
if proxy is not None:
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user