Skip to content

Commit

Permalink
Use r.raise_for_status() instead of checking r.status_code
Browse files Browse the repository at this point in the history
  • Loading branch information
vterron committed May 11, 2022
1 parent 89ce321 commit 25c9895
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/fear_and_greed/cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ class Fetcher:

def __call__(self) -> dict:
headers = {
'User-Agent': 'Mozilla',
"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))
r.raise_for_status()
return r.json()


Expand Down

0 comments on commit 25c9895

Please sign in to comment.