关于爬虫访问页面异常的获取:
HTTPError 和 URLError的区别:
前者是后者的一个子类,所以在捕获异常是要把HTTPError写在URLError的前面。
附加一个常见的http状态码及其对应状态:
https://blog.csdn.net/qq_40806970/article/details/100532946?ops_request_misc=%7B%22request%5Fid%22%3A%22158235425319724846422933%22%2C%22scm%22%3A%2220140713.130056874…%22%7D&request_id=158235425319724846422933&biz_id=0&utm_source=distribute.pc_search_result.none-task
import urllib.error
import urllib.request
req = urllib.request.Request('https://www.ooxx-fish.com')
###方法一
try:
response = urllib.request.urlopen(req)
except urllib.error