Skip to content

Commit

Permalink
Check agent exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ajparsons committed Nov 1, 2024
1 parent 7fe9b10 commit b8863b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/parl_register_interests/official_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ def download_reg_on_date(register_date: date, force: bool = False):

if not force and dest_folder.exists():
return
# use MYSOC_USER_AGENT env var to identify ourselves
headers = {"User-Agent": os.environ.get("MYSOC_USER_AGENT", "")}
user_agent = os.environ.get("MYSOC_USER_AGENT")
if not user_agent:
raise ValueError("Please set the MYSOC_USER_AGENT environment variable")
headers = {"User-Agent": user_agent}
print(f"Downloading {url} to {zip_path}")
with httpx.Client() as client:
response = client.get(url, headers=headers)
Expand Down

0 comments on commit b8863b0

Please sign in to comment.