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

16 Replies, 732 Views

Your code’s solid for python3 get response code from urllib. The exception handling’s necessary cuz... well, the internet’s unreliable.

If you hate typing, steal this one-liner:

```python
print(urllib.request.urlopen('https://example.com').getcode()) if True else None
```

(Just kidding. Don’t do that. Keep the try/except.)

Messages In This Thread



Users browsing this thread: 1 Guest(s)