Use requests.Session.
This commit is contained in:
parent
1c3fa864e9
commit
8a2e72b5cf
1 changed files with 4 additions and 1 deletions
|
@ -67,6 +67,9 @@ def int_or_none(x):
|
|||
|
||||
# API ##############################################################################################
|
||||
|
||||
session = requests.Session()
|
||||
session.headers.update(HEADERS)
|
||||
|
||||
def get(url, retries=1):
|
||||
start_time = time.time()
|
||||
|
||||
|
@ -74,7 +77,7 @@ def get(url, retries=1):
|
|||
while retries > 0:
|
||||
log.loud(url)
|
||||
try:
|
||||
response = requests.get(url, headers=HEADERS, timeout=2)
|
||||
response = session.get(url, timeout=2)
|
||||
response.raise_for_status()
|
||||
break
|
||||
except requests.exceptions.HTTPError as exc:
|
||||
|
|
Loading…
Reference in a new issue