RIshu
RIshu

Reputation: 217

500 + Website Check in Python for multiple status

Upvotes: 0

Views: 1531

Answers (1)

Venkata Vamsy
Venkata Vamsy

Reputation: 92

I think you can the page presence with this code:

import httplib
from urlparse import urlparse

def chkUrl(url):
    p = urlparse(url)
    conn = httplib.HTTPConnection(p.netloc)
    conn.request('HEAD', p.path)
    resp = conn.getresponse()
    return resp.status < 400

if __name__ == '__main__':
    print chkUrl('http://www.stackoverflow.com') # True
    print chkUrl('http://stackoverflow.com/notarealpage.html') # False

Upvotes: 1

Related Questions