首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    检测地址能否打开[python] 原

    import urllib.request   import time   opener = urllib.request.build_opener()   opener.addheaders = [('User-agent', 'Mozilla/49.0.2')]   #这个是你放网址的文件名,改过来就可以了   # file = open('test.txt')   # lines = file.readlines()   aa=['http://www.baidu.com/','http://www.baidu.com']   # for line in lines:   #     temp=line.replace('\n','')   #     aa.append(temp)   # print(aa)   print('开始检查:')   for a in aa:       tempUrl = a       try :           opener.open(tempUrl)           print(tempUrl+'没问题')       except urllib.error.HTTPError:           print(tempUrl+'=访问页面出错')           time.sleep(2)       except urllib.error.URLError:           print(tempUrl+'=访问页面出错')           time.sleep(2)       time.sleep(0.1)

    01
    领券