修改爬虫的HTTP请求
来源:互联网 发布:淘宝有好货报名入口 编辑:程序博客网 时间:2024/06/06 01:25
如果遇到会对请求头进行审查的网站,他的status_code会为非200,这时候想要正常爬取,需要新建键值对kv = {’user-agent','Mozilla/5.0'},并在requests.get()里面加上headers = kv
下面是实际代码
import requestsurl = "https://item.jd.com/12029500.html?cpdad=1DLSUE"kv = {'user-agent','Mozilla/5.0'}try:r = requests.get(url, headers = kv)r.raise_for_status()r.encoding = r.apparent_encodingprint(r.text[:1000])print("爬取成功")except:print("爬取失败")
阅读全文
0 0
- 修改爬虫的HTTP请求
- 修改Apache的http请求包上限
- 网络爬虫-http请求方式
- 爬虫学习3.2 HTTP请求的python实现--Requests
- HTTP请求中的User-Agent 判断浏览器类型的各种方法 网络爬虫的请求标示
- 在WebCollector爬虫中,自定义http请求
- 爬虫:HTTP请求和requests库
- python爬虫和http请求协议
- http请求(Python爬虫headers)
- Python爬虫入门2--请求(HTTP)
- http请求头详解and爬虫
- 一个可以修改HTTP请求头的FF插件
- node爬虫HTTP请求中的form data和request payload的区别
- 爬虫学习3.2 HTTP请求的python实现--urllib2/urllib实现
- 妹子图爬虫,最重要的是请求头headers设置'Referer':'http://www.mzitu.com/'
- HttpServletRequestWrapper重新并修改http请求信息
- fiddler用法:修改http请求返回信息
- Fiddler拦截http请求修改数据
- 什么时候使用CountDownLatch
- 每日一练 20171110
- 使用python selenium TouchAction模拟实现lCalendar滚动和点击效果
- 准备报考信息系统项目管理工程师中级职称
- SQLZOO习题答案 The nobel table can be used to practice more SUM and COUNT functions./zh
- 修改爬虫的HTTP请求
- 关于Visual Studio "当前不会命中断点.还没有为该文档加载任何符号"的解决方法
- 执行 composer require 出现Warning: This development build of composer is over 60 days old.
- NOIp(lus)2017总结
- MySQL单机多实例配置(转载http://skypegnu1.blog.51cto.com/8991766/1441188)
- Struts2学习笔记-<s:append>与<s:merge>标签
- 判断一个整数的奇偶性
- fffff
- zookeeper的使用