批量判断网站可否访问,可使用urllib的getcode()方法python
#!/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)