Python check if website exists

后端 未结 8 1947
甜味超标
甜味超标 2020-11-27 12:51

I wanted to check if a certain website exists, this is what I\'m doing:

user_agent = \'Mozilla/20.0.1 (compatible; MSIE 5.5; Windows NT)\'
headers = { \'User         


        
8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 13:13

    code:

    a="http://www.example.com"
    try:    
        print urllib.urlopen(a)
    except:
        print a+"  site does not exist"
    

提交回复
热议问题