ppf: use timeout and only 1 try for http

This commit is contained in:
rofl0r
2019-01-07 05:37:44 +00:00
parent 497f8b2050
commit ad7c7fce67

2
ppf.py
View File

@@ -42,7 +42,7 @@ def fetch_contents(url):
'Cache-Control: max-age=0',
]
proxies = [rocksock.RocksockProxyFromURL('socks4://%s' % random.choice( config.torhosts ))]
http = RsHttp(host,ssl=ssl,port=port, keep_alive=True, follow_redirects=True, auto_set_cookies=True, proxies=proxies, user_agent='Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0')
http = RsHttp(host,ssl=ssl,port=port, keep_alive=True, timeout=15, max_tries=1, follow_redirects=True, auto_set_cookies=True, proxies=proxies, user_agent='Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0')
if not http.connect(): return ''
hdr, res = http.get(uri, headers)
res = res.encode('utf-8') if isinstance(res, unicode) else res