[b]"How to Python3 get response code from urllib? Best way to check HTTP status?"[/b] or [b]"Python3 get response

16 Replies, 736 Views

Yeah, urllib can be a pain for python3 get response code from urllib stuff. Your code’s actually fine, but if you want something simpler, try the `requests` lib.

```python
import requests
r = requests.get('https://example.com')
print(r.status_code)
```

Way cleaner, no nesting. Plus, `requests` handles redirects and timeouts better. Downside? It’s an extra dependency.

Also, urllib hides the code cuz it’s low-level—meant for more control, not convenience.

Messages In This Thread



Users browsing this thread: 1 Guest(s)