原文链接:https://blog.csdn.net/cheny1p1ng/article/details/90780024

旧版本DefaultHttpClient 使用getCookieStore直接获取cookies信息,但是apache升级4.5后,DefaultHttpClient过期了,使用CloseableHttpClient做为替换获取cookies的代码如下:

//CloseableHttpClient替换DefaultHttpClient获取cookies
CookieStore store = new BasicCookieStore();
CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(store).build();
HttpResponse response = httpClient.execute(get);
result = EntityUtils.toString(response.getEntity(),"utf-8");
System.out.printf(result);
List<Cookie> CookieList = store.getCookies();

  

设置cookies信息

CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(this.store).build();

  

(九)HttpClient获取cookies的更多相关文章

  1. 【接口测试】使用httpClient获取cookies+携带获取的cookies访问get接口

    数据准备 在本机或者远端机器安装部署moco-runner(参考:https://blog.csdn.net/qq_32706349/article/details/80472445) 这里我们只需要 ...

  2. httpclient获取cookies

    Cookie[] cookies = httpClient.getState().getCookies(); System.out.println("==========Cookies=== ...

  3. C# httpclient获取cookies实现模拟web登录

    目前在公司做一款平台化的产品,我主要负责PC端上的开发,在产品推荐过程中为了节省开发时间很多功能模块没来得及做原生,用CEF嵌入了很多带功能web页面,与客户端进行交互从而实现功能. 在二期开发中,产 ...

  4. HttpClient获取Cookie的两种方式

    转载:http://blog.csdn.net/zhangbinu/article/details/72777620 一.旧版本的HttpClient获取Cookies p.s. 该方式官方已不推荐使 ...

  5. Java通过httpclient获取cookie模拟登录

    package Step1; import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.Htt ...

  6. java HttpClient 获取页面Cookie信息

    HttpClient client = new HttpClient(); GetMethod get=new GetMethod("http://www.baidu.com"); ...

  7. VC获取cookies的几种方法

    方法一: CInternetSession::GetCookie This member function implements the behavior of the Win32 function  ...

  8. C# HttpWebRequest获取COOKIES

    C# HttpWebRequest获取COOKIES byte[] bytes = Encoding.Default.GetBytes(_post); CookieContainer myCookie ...

  9. 新旧apache HttpClient 获取httpClient方法

    在apache httpclient 4.3版本中对很多旧的类进行了deprecated标注,通常比较常用的就是下面两个类了. DefaultHttpClient -> CloseableHtt ...

随机推荐

  1. poj3613 求经过n条边的最短路 ----矩阵玩出新高度 。

    For their physical fitness program, N (2 ≤ N ≤ 1,000,000) cows have decided to run a relay race usin ...

  2. Spring MVC必须知道的执行流程

    Spring MVC的执行流程 一.名词解释 1.前端控制器(DispatcherServlet) 接收请求,响应结果,相当于转发器,中央处理器 2.处理器映射器(HandlerMapping) 根据 ...

  3. java三个时间类常用法

    1.System.currentTimeMillis();    获取当前时间戳    System的获取时间戳的方法,只能获取不能进行其他的操作,简单的毫秒计算可以使用 2.Date(),Date( ...

  4. Cookie&Sission 部分方法

    Cookie:创建Cookie:Cookie cookie = new Cookie(String cookieName,String cookieValue); cookie.setMaxAge(i ...

  5. Linux的运行等级与目标

    在老的 Linux 发行版本中,系统运行分成不同的运行级别(run level),不同的级别所启动的服务搭配有所不同.较新的 Linux 发行版本,比如 CentOS 7+,已经将运行级别替换成另一个 ...

  6. Java 泛型与集合

    1.List练习,请用泛型的写法来完成. 已知有一个Worker 类如下: public class Worker  { private int age; private String name; p ...

  7. Linux服务器程序--大数据量高并发系统设计

         在Linux服务器程序中,让系统能够提供以更少的资源提供更多的并发和响应效率决定了程序设计价值!怎样去实现这个目标,它其实是这么多年以来一直追逐的东西.最开始写代码时候,省去一个条件语句.用 ...

  8. redis 缓存穿透,缓存雪崩,缓存击穿

    1.缓存穿透:缓存穿透是指查询一个不存在的数据,由于缓存是不命中,将去查询数据库,但是数据库也无此记录,这将导致这个不存在的数据每次请求都要到存储层去查询,失去了缓存的意义.在流量大时,可能DB就挂掉 ...

  9. BZOJ1001 狼抓兔子 题解

    裸的最小割,转化成最大流即可. #include <bits/stdc++.h> int n,m; int S,T; int mincost; int head[6001000],tot= ...

  10. 微软:悬赏10万美金破解 Linux 系统

    微软选择了 Linux 系统作为物联网平台,并且悬赏10万美金邀请黑客来进行破解. 当然,该悬赏计划不是针对所有的 Linux 系统,而是特别针对微软的物联网端对端安全平台Azure Sphere.本 ...