Skip to content

Commit bf61eb3

Browse files
authored
Merge pull request #138 from radnvlad/feature/fix_useragent
Force a User-Agent string that is NOT the default Python-urlib.
2 parents b966d1c + fe802ba commit bf61eb3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tockloader/tab.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ def __init__(self, tab_path, args=argparse.Namespace()):
3333
else:
3434
try:
3535
# Otherwise download it as a URL.
36-
with urllib.request.urlopen(tab_path) as response:
36+
request = urllib.request.Request(
37+
tab_path,
38+
headers={"User-Agent": "tockloader"},
39+
)
40+
with urllib.request.urlopen(request) as response:
3741
tmp_file = tempfile.TemporaryFile()
3842
# Copy the downloaded response to our temporary file.
3943
shutil.copyfileobj(response, tmp_file)

0 commit comments

Comments
 (0)