ppf: change user-agent; use headers
This commit is contained in:
13
ppf.py
13
ppf.py
@@ -13,11 +13,7 @@ from http2 import RsHttp, _parse_url
|
|||||||
import rocksock
|
import rocksock
|
||||||
|
|
||||||
base_header = {
|
base_header = {
|
||||||
'Accept-Language':'en-US,en;q=0.8',
|
|
||||||
'Cache-Control':'max-age=0',
|
|
||||||
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||||
'DNT': '1',
|
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
searx_instances = ('https://searx.me', 'https://searx.xyz', 'https://searx.site', 'https://searx.win', 'https://searx.ru', 'https://stemy.me/searx', 'https://searx.at', 'https://listi.me', 'https://searx.dk', 'https://searx.laquadrature.net' )
|
searx_instances = ('https://searx.me', 'https://searx.xyz', 'https://searx.site', 'https://searx.win', 'https://searx.ru', 'https://stemy.me/searx', 'https://searx.at', 'https://listi.me', 'https://searx.dk', 'https://searx.laquadrature.net' )
|
||||||
@@ -40,12 +36,15 @@ def import_from_file(fn, sqlite):
|
|||||||
sqlite.commit()
|
sqlite.commit()
|
||||||
|
|
||||||
def fetch_contents(url):
|
def fetch_contents(url):
|
||||||
headers = base_header
|
|
||||||
host, port, ssl, uri = _parse_url(url)
|
host, port, ssl, uri = _parse_url(url)
|
||||||
|
headers=[
|
||||||
|
'Accept-Language: en-US,en;q=0.8',
|
||||||
|
'Cache-Control: max-age=0',
|
||||||
|
]
|
||||||
proxies = [rocksock.RocksockProxyFromURL('socks4://%s' % random.choice( config.torhosts ))]
|
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="curl/7.60.0")
|
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')
|
||||||
if not http.connect(): return ''
|
if not http.connect(): return ''
|
||||||
hdr, res = http.get(uri)
|
hdr, res = http.get(uri, headers)
|
||||||
res = res.encode('utf-8') if isinstance(res, unicode) else res
|
res = res.encode('utf-8') if isinstance(res, unicode) else res
|
||||||
for retry_message in retry_messages:
|
for retry_message in retry_messages:
|
||||||
if retry_message in res: return ''
|
if retry_message in res: return ''
|
||||||
|
|||||||
Reference in New Issue
Block a user