文章详情页
网页爬虫 - Python爬虫返回状态码与实际情况不符?
浏览:222日期: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. css - 关于伪类背景问题2. html - 移动端radio无法选中3. apache - 怎么给localhost后面默认加上8080端口4. html5 - 如何实现图中的刻度渐变效果?5. python - 用scrapy-splash爬取网站 为啥iframe下的内容没有被返回6. mysql - 数据库建字段,默认值空和empty string有什么区别 1107. python - django的模板预加载8. 关于Navicat连接到mysql,我改了root的密码后,Navicat连接报错1862?9. mysql起不来了,为什么?10. mysql里show full processlist,进程很少
排行榜
