原文链接: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. CF894B Ralph And His Magic Field

    题目链接:http://codeforces.com/contest/894/problem/B 题目大意: 往一个 \(n \times m\) 的网格中填数字 \((1 \le n,m \le 1 ...

  2. SQL——SQL约束

    SQL约束 - 用于限制加入表的数据的类型    可以在创建表时规定约束(通过 CREATE TABLE 语句),或者在表创建之后也可以(通过 ALTER TABLE 语句).    NOT NULL ...

  3. SPL基础接口

    Iterator 迭代器接口 SPL规定,所有实现了Iterator接口的class,都可以用在foreach Loop中.Iterator接口中包含5个必须实现的方法: interface Iter ...

  4. EL表达式用法---查询博客

    jsp脚本:<%=request.getAttribute(name)%>EL表达式替代上面的脚本:${requestScope.name} 使用EL最主要的作用是获得四大域中的数据,格式 ...

  5. 有点干货 | Jdk1.8新特性实战篇(41个案例)

    作者:小傅哥 博客:https://bugstack.cn - 汇总系列原创专题文章 沉淀.分享.成长,让自己和他人都能有所收获!

  6. windows10安全及性能优化

    一.关闭一些服务. Google 更新服务 (gupdate) Google 更新服务 (gupdatem) HomeGroupListener HomeGroupProvider Xbox Live ...

  7. ubuntu 下安装 mysql 启动报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

    环境: ubuntu LTS 18.04.1 mysql Ver 14.14 Distrib 5.7.29, for Linux (x86_64) 初探 linux,按照如下安装完mysql sudo ...

  8. unicode、encode、decode

    1.encode与decode:unicode经过encode -> utf-8,反过来为decode. 爬虫读取网页内容和pandas读取csv时,会把读取到的文字内容转成unicode,当我 ...

  9. 概念辨析-Hardware Description还是Hardware Developing?

    https://mp.weixin.qq.com/s/j4Ndo1R4Go9IaGbhE_nsTg   Verilog, standardized as IEEE 1364, is a hardwar ...

  10. css定位和css3的基本

    定位方式:position需要搭配left|right |top |bottom 1.相对定位:相对于自身的位置进行偏移position: relative; 2.绝对定位:相对于有position属 ...