文章详情页
网页爬虫 - Python爬虫返回状态码与实际情况不符?
浏览:297日期:2022-09-03 18:57:11
问题描述
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. docker start -a dockername 老是卡住,什么情况?2. 小白问题getDay()3. 请问一下各位老鸟 我一直在学习独孤九贱 现在是在tp5 今天发现 这个系列视频没有实战4. 求救一下,用新版的phpstudy,数据库过段时间会消失是什么情况?5. 关于docker下的nginx压力测试6. 老师,请问我打开browsersync出现这个问题怎么解决啊?7. golang - 用IDE看docker源码时的小问题8. python - 多线程小白求问这样的IP要怎么实现多线程print?9. 是真的吗? Linux 下 mysql 使用 localhost 比 127.0.0.1 快10. mysql问题请教
排行榜

网公网安备