Skip to content

Commit

Permalink
Fix StackOverflow 403-ing due to missing User-Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
dopplershift committed Oct 27, 2023
1 parent 60b1b75 commit 3c899f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion code/stackoverflow.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def check_stack_overflow(event, context):
asana = AsanaSubmit(get_asana_client())

for item in config:
xml = urllib.request.urlopen(f'https://stackoverflow.com/feeds/tag?tagnames={item["tag"]}&sort=newest')
url = f'https://stackoverflow.com/feeds/tag?tagnames={item["tag"]}&sort=newest'
req = urllib.request.Request(url, headers={'User-Agent': 'Asanabot'})
xml = urllib.request.urlopen(req)
content = xml.read()
root = ET.fromstring(content)
last_update = item['updated']
Expand Down

0 comments on commit 3c899f0

Please sign in to comment.