Skip to content

Commit

Permalink
provide bogus user agent to avoid '418 I'm a teapot'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSnoozer committed May 11, 2022
1 parent 9f06135 commit 447be8c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/fear_and_greed/cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ class Fetcher:
"""Fetcher gets the HTML contents of CNN's Fear & Greed Index website."""

def __call__(self) -> dict:
r = requests.get(URL)
headers = {
'User-Agent': 'Mozilla',
}
r = requests.get(URL, headers=headers)
if r.status_code != 200:
raise ValueError("Unexpected response code: '{status_code}', response: '{response}'".format(
status_code=r.status_code, response=r.text))
return r.json()


Expand Down

0 comments on commit 447be8c

Please sign in to comment.