Skip to content

Commit

Permalink
fix: 🔨 add user agent to downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
marcodarko committed Nov 19, 2024
1 parent a6a1e0c commit 200a37d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 200a37d

Please sign in to comment.