批量判断网站能否访问,可以使用urllib的getcode()方法
代码语言:javascript
复制
#!/usr/bin/env python3 # -*- coding: utf-8 -*-
from urllib.request import urlopen
url = 'http://www.baidu.com'
resp = urlopen(url)
code = resp.getcode()
print('the result is :', code)
(adsbygoogle = window.adsbygoogle || []).push({});