use default headers with requests backend
This commit is contained in:
parent
11376c5d7d
commit
0df326eaf8
2 changed files with 3 additions and 1 deletions
|
@ -102,6 +102,8 @@ def read_url(url, data=None, headers=None, timeout=cache_timeout, valid=None, un
|
|||
url_headers = {}
|
||||
if not result:
|
||||
if USE_REQUESTS:
|
||||
if headers is None:
|
||||
headers = DEFAULT_HEADERS.copy()
|
||||
r = requests_session.get(url, headers=headers)
|
||||
for key in r.headers:
|
||||
url_headers[key.lower()] = r.headers[key]
|
||||
|
|
|
@ -21,7 +21,7 @@ from chardet.universaldetector import UniversalDetector
|
|||
DEBUG = False
|
||||
# Default headers for HTTP requests.
|
||||
DEFAULT_HEADERS = {
|
||||
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0',
|
||||
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0',
|
||||
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||
'Accept-Language': 'en-US,en;q=0.8,fr;q=0.6,de;q=0.4',
|
||||
|
|
Loading…
Reference in a new issue