Reputation: 3
What is the best way to test if a URL exists in python, I currently use cURL however I wanted to switch to use python
In cURL I use something like
curl http://www.google.com | tidy -i
together with a bash script
Upvotes: 0
Views: 63
Reputation: 2362
The quickest way is probably something like
import httplib
try:
url = httplib.HTTPConnection('yahoo.com')
url.connect()
except httplib.HTTPException as ex:
print "not connected"
Upvotes: 3