批量判斷網站可否訪問,可使用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)