Created
March 9, 2019 10:23
-
-
Save sandgate-dev/4d67662ae933e3539322e06b40903c1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # How can I determine if anything at the given url exists | |
| # https://stackoverflow.com/a/1966141/5983691 | |
| # | |
| # 4xx status codes describe client errors (like "404 Not found") | |
| # 5xx status codes describe server errors (like "500 Internal server error") | |
| from urllib2 import urlopen | |
| code = urlopen("http://example.com/").code | |
| if (code / 100 >= 4): | |
| print "Nothing there." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment