Welcome, guest | Sign In | My Account | Store | Cart
from httplib import HTTP 
from urlparse import urlparse 

def checkURL(url): 
     p = urlparse(url) 
     h = HTTP(p[1]) 
     h.putrequest('HEAD', p[2]) 
     h.endheaders() 
     if h.getreply()[0] == 200: return 1 
     else: return 0 

if __name__ == '__main__': 
     assert checkURL('http://slashdot.org') 
     assert not checkURL('http://slashdot.org/notadirectory') 

History

  • revision 4 (22 years ago)
  • previous revisions are not available