Skip to content

Commit

Permalink
添加更加严谨的代理校验规则(一些非法代理也会返回200状态码)
Browse files Browse the repository at this point in the history
  • Loading branch information
DustinPT committed Nov 14, 2018
1 parent 428359c commit 3c3ddaf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Util/utilFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def validUsefulProxy(proxy):
try:
# 超过20秒的代理就不要了
r = requests.get('http://httpbin.org/ip', proxies=proxies, timeout=10, verify=False)
if r.status_code == 200:
if r.status_code == 200 and r.headers['content-type'].lower().find('application/json') != -1 and r.json()['origin']:
# logger.info('%s is ok' % proxy)
return True
except Exception as e:
Expand Down

0 comments on commit 3c3ddaf

Please sign in to comment.