For a quick and dirty solution, I sometimes use this:
```python
response = requests.get(url)
if not response.ok:
print(f"Failed with status {response.status_code}")
else:
# do stuff
```
But for real projects, `try-except` with specific exceptions is the way to go. Also, the `timeout` param is a must—don’t let requests hang forever.
```python
response = requests.get(url)
if not response.ok:
print(f"Failed with status {response.status_code}")
else:
# do stuff
```
But for real projects, `try-except` with specific exceptions is the way to go. Also, the `timeout` param is a must—don’t let requests hang forever.
