CurvedTalk331
CurvedTalk331

Reputation: 3

Test to see if URL exists

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

Answers (1)

DavidJB
DavidJB

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

Related Questions