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 ##############################################################################################
|
# API ##############################################################################################
|
||||||
|
|
||||||
|
session = requests.Session()
|
||||||
|
session.headers.update(HEADERS)
|
||||||
|
|
||||||
def get(url, retries=1):
|
def get(url, retries=1):
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
|
@ -74,7 +77,7 @@ def get(url, retries=1):
|
||||||
while retries > 0:
|
while retries > 0:
|
||||||
log.loud(url)
|
log.loud(url)
|
||||||
try:
|
try:
|
||||||
response = requests.get(url, headers=HEADERS, timeout=2)
|
response = session.get(url, timeout=2)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
break
|
break
|
||||||
except requests.exceptions.HTTPError as exc:
|
except requests.exceptions.HTTPError as exc:
|
||||||
|
|
Loading…
Reference in a new issue