https://p.3.cn/prices/mgets爬取京东商品信息报错error pdos_captcha
遇到这个问题首先是没有添加Headers请求头,我把请求头加上之后,不报错也没有值返回,头疼了一会儿之后发现大概是我用的请求不对,应该使用Get请求。
public static String httpPost(String url,Map<String, String> headers){CloseableHttpClient httpClient = HttpClients.createDefault();HttpPost httpPost = new HttpPost(url);if (headers != null) {Set<String> keys = headers.keySet();for (Iterator<String> i = keys.iterator(); i.hasNext();) {String key = (String) i.next();httpPost.addHeader(key, headers.get(key));}}CloseableHttpResponse response = null;String result = null;try {List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8"));httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");// 执行请求response = httpClient.execute(httpPost);HttpEntity entity = response.getEntity();if (null != entity) {result = EntityUtils.toString(entity, ContentType.getOrDefault(entity).getCharset());EntityUtils.consume(entity);}} catch (IOException e) {} finally {try {if (response != null) {response.close();}} catch (IOException e) {}httpPost.releaseConnection();}return result;}
public static void main(String[] args) throws ParseException { Map param=new HashMap();param.put("User-agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36");param.put("Cookie","Cookie");param.put("Connection","keep-alive");param.put("Accept","*/*");param.put("Accept-Encoding","gzip, deflate, sdch");param.put("Accept-Language","zh-CN,zh;q=0.8");param.put("Host","p.3.cn");param.put("Referer","https://book.jd.com/booktop/0-0-0.html?category=1713-0-0-0-10001-1");String rs=httpPost("https://p.3.cn/prices/mgets?area=19&skuIds=J_100002133548",param);System.out.println("rs======================="+rs);
}
添加Headers请求头以及直接使用Get请求就ok啦啦~~~一开始我是把area以及skuIds也放到了Map里面当做参数进行请求,使用Get请求的话直接area和skuIds放到url地址里面请求即可
https://p.3.cn/prices/mgets爬取京东商品信息报错error pdos_captcha相关推荐
- Day06,selenium的剩余用法、万能登录破解和爬取京东商品信息,及破解极验滑动验证码...
一.自动登录抽屉新热榜 from selenium import webdriver import timedriver = webdriver.Chrome(r'D:\BaiduNetdiskDow ...
- python爬取京东商品信息代码_爬取京东商品信息
利用 BeautifulSoup + Requests 爬取京东商品信息并保存在Excel中 一.查看网页信息 打开京东商城,随便输入个商品,就选固态硬盘吧 先看看 URL 的规律,可以看到我们输入的 ...
- go爬虫和python爬虫哪个好_python 爬虫实战项目--爬取京东商品信息(价格、优惠、排名、好评率等)-Go语言中文社区...
利用splash爬取京东商品信息 一.环境 window7 python3.5 pycharm scrapy scrapy-splash MySQL 二.简介 为了体验scrapy-splash 的动 ...
- layui获取input信息_python爬虫—用selenium爬取京东商品信息
python爬虫--用selenium爬取京东商品信息 1.先附上效果图(我偷懒只爬了4页) 2.京东的网址https://www.jd.com/ 3.我这里是不加载图片,加快爬取速度,也可以用Hea ...
- python爬虫爬取京东商品评价_python爬取京东商品信息及评论
''' 爬取京东商品信息: 功能: 通过chromeDrive进行模拟访问需要爬取的京东商品详情页(https://item.jd.com/100003196609.html)并且程序支持多个页面爬取 ...
- python爬虫爬商品库存_python爬虫实践——爬取京东商品信息
1 ''' 2 爬取京东商品信息:3 请求url:4 https://www.jd.com/5 提取商品信息:6 1.商品详情页7 2.商品名称8 3.商品价格9 4.评价人数10 5.商品商家11 ...
- Selenium介绍--实例爬取京东商品信息与图片
目录 一.Selenium简介 二.Selenium组成 三.Selenium特点 四.Selenium的基本使用 1.下载所用浏览器需要的驱动 2.创建项目并导入依赖 3.入门 3.代码演示 五.实 ...
- 八个commit让你学会爬取京东商品信息
我发现现在不用标题党的套路还真不好吸引人,最近在做相关的事情,从而稍微总结出了一些文字.我一贯的想法吧,虽然才疏学浅,但是还是希望能帮助需要的人.博客园实在不适合这种章回体的文章.这里,我贴出正文的前 ...
- python爬取京东商品属性_python爬虫小项目:爬取京东商品信息
#爬取京东手机信息 import requests from bs4 import BeautifulSoup from selenium import webdriver import re imp ...
最新文章
- 锐捷大中型企业VLAN网络方案
- 豆瓣FLASHMP3播放器
- Xamarin中Unsupported major.minor version 52.0问题解决
- javascript捕获ocx事件
- 跟我学Telerik公司的RadControls控件(四)
- 如何卸载mysql server 2005_如何卸载SQL Server 2005
- matlab中仿真丢包,使用MATLAB进行误比特率(BER)仿真----转载
- 邬贺铨/余晓晖/田溯宁…千家从业者,数十位行业大咖共同烹制了一场怎样的AIoT“盛宴”?
- Alfred Remote初体验
- DRF如何使用serializer进行验证数据
- 一些特殊符号%$等等,如何写在xml,TextView中
- c语言fprintf 数组,C语言fprintf()函数:格式化输出到一个流中
- 解读:【阿里热线小蜜】实时语音对话场景下的算法实践
- 4.5.2 地址变换机构 4.5.3 访问内存的有效时间
- 网易云信Web IM入门(一)
- 联想z400成功带起外置显卡gtx1050
- 配置oem 13c以监控管理数据库
- 常见的均值不等式的使用技巧
- linux中fflush函数和printf函数 【转】
- 5.Flink对接Kafka入门