20250119.1737302954
This commit is contained in:
parent
177ed7f0f1
commit
4294736372
1 changed files with 5 additions and 1 deletions
|
@ -114,7 +114,11 @@ def fetch_data(url, headers={}, data=None, rjson=True, log=True):
|
||||||
if response.status != 200:
|
if response.status != 200:
|
||||||
logit.error(response.read())
|
logit.error(response.read())
|
||||||
sys.exit(f"HTTP error {response.status}")
|
sys.exit(f"HTTP error {response.status}")
|
||||||
|
try:
|
||||||
response_data = response.read().decode("utf-8")
|
response_data = response.read().decode("utf-8")
|
||||||
|
except UnicodeDecodeError as e:
|
||||||
|
logit.error(e)
|
||||||
|
response_data = response.read()
|
||||||
logit.info(response_data) if log else None
|
logit.info(response_data) if log else None
|
||||||
if not rjson:
|
if not rjson:
|
||||||
return response_data
|
return response_data
|
||||||
|
|
Loading…
Add table
Reference in a new issue