Python requests 爬取网页源码问题

python requests爬取网页内容出现

500 Server Error


An internal server error occured.

怎么解决

这个属于服务器内部错误了,requests库可以返回http状态码: requests.get('http://www.baidu.com').status_code 。通过它捕捉异常即可。记住一点,
爬虫能获取的数据是用户能看到的,如果你自己手动输入网址访问也出现500,那肯定是目标服务器出错了。