重复用一个代理ip,当超时6次换ip

This commit is contained in:
Administrator 2022-12-16 15:19:46 +08:00
parent 787b185794
commit fb95b5e537

View File

@ -27,8 +27,9 @@ def request_with_proxy(url):
result = requests.get(url, proxies=proxies, timeout=5).text
#hku_info("use proxy: {}".format(proxies['http']))
return result
except:
new = True
except Exception as e:
if i == 6:
new = True
time.sleep(2)
raise Exception("无法通过代理访问!")