From 200a37d45334e0d0a8c795c6bc75e2e8159f60ec Mon Sep 17 00:00:00 2001 From: Marco Cano Date: Tue, 19 Nov 2024 14:15:58 -0800 Subject: [PATCH] fix: :hammer: add user agent to downloader --- src/utils/downloader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/downloader.py b/src/utils/downloader.py index 265299c9..57b5a738 100644 --- a/src/utils/downloader.py +++ b/src/utils/downloader.py @@ -121,7 +121,10 @@ def get_raw(self): def download(url, timeout=5, raise_error=True): try: - response = requests.get(url, timeout=timeout) + headers = { + 'User-Agent': 'SmartAPI' # UA required by GitHub + } + response = requests.get(url, headers=headers, timeout=timeout) if raise_error: response.raise_for_status() result = RequestsParser(response) @@ -152,7 +155,7 @@ async def download_async(url, timeout=20, raise_error=True): def download_mapping(url): headers = { - 'User-Agent': 'SmartAPI' + 'User-Agent': 'SmartAPI' # UA required by GitHub } response = requests.get(url, headers=headers, timeout=60) response.raise_for_status()