文章详情页
网页爬虫 - Python爬虫返回状态码与实际情况不符?
问题描述
import urllib2opener = urllib2.build_opener()html = Noneresponse = Noneresponse = opener.open(’http://www.sxxrcs.com/was5/web/’)html = response.codeprint html
比如这个爬虫,输出状态码是200。
可是直接访问http://www.sxxrcs.com/was5/web/是404,抓包响应的也是404,请问这是为什么?
问题解答
回答1:用requests吧
import requestsr = requests.get(’http://www.sxxrcs.com/was5/web/’)print r.status_codeprint r.text回答2:
200正常啊,requests方便快捷。
相关文章:
1. android - 使用listview加载不同item,数据填充错误。2. javascript - 读js权威指南“作为值得函数”产生了疑惑,求释疑3. file - Python如何读文件内容修改后写回原文件4. 请问带渐变背景的进度条如何实现?求给点思路5. boostrap怎么在移动端不显示sidebar?6. python中merge后文件莫名变得非常大7. python3.x - python中的虚拟环境怎样设置一直处于激活状态8. javascript - 为什么 process.stdin 会有 write 方法◔ ‸◔?9. javascript - prismplayer播放器全屏问题10. python - UTC格式转换成本地时间
排行榜