Skip to content

Commit 200a37d

Browse files
committed
fix: 🔨 add user agent to downloader
1 parent a6a1e0c commit 200a37d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/utils/downloader.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ def get_raw(self):
121121

122122
def download(url, timeout=5, raise_error=True):
123123
try:
124-
response = requests.get(url, timeout=timeout)
124+
headers = {
125+
'User-Agent': 'SmartAPI' # UA required by GitHub
126+
}
127+
response = requests.get(url, headers=headers, timeout=timeout)
125128
if raise_error:
126129
response.raise_for_status()
127130
result = RequestsParser(response)
@@ -152,7 +155,7 @@ async def download_async(url, timeout=20, raise_error=True):
152155

153156
def download_mapping(url):
154157
headers = {
155-
'User-Agent': 'SmartAPI'
158+
'User-Agent': 'SmartAPI' # UA required by GitHub
156159
}
157160
response = requests.get(url, headers=headers, timeout=60)
158161
response.raise_for_status()

0 commit comments

Comments
 (0)