Since you only need to check response codes you might want to only issue a HEAD request, this way you avoid downloading the page and discard the content.
HEAD
If you want to use the standard library you can do something like:
request = urllib.request.Request(url, method="HEAD") response = urllib.request.urlopen(request)
Unfortunately this will follow redirects, so you end up issuing multiple requests.
I'm sure there's a way to ignore redirects but you'd have to check the documentation.
Thanks!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Since you only need to check response codes you might want to only issue a
HEAD
request, this way you avoid downloading the page and discard the content.If you want to use the standard library you can do something like:
Unfortunately this will follow redirects, so you end up issuing multiple requests.
I'm sure there's a way to ignore redirects but you'd have to check the documentation.
Thanks!