获取cookie后,使用cookie进行接下来的自动化操作
Posted Blade blog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了获取cookie后,使用cookie进行接下来的自动化操作相关的知识,希望对你有一定的参考价值。
System.setProperty("javax.net.ssl.trustStore", certPath); public void uploadComponent() throws Exception { HttpClient httpclient = HttpClientBuilder.create().build(); HttpPut httpget = new HttpPut(postURI); handleCookie(httpget); httpget.setHeader("Content-Type", "application/json;charset=UTF-8"); httpget.setEntity(getParamaters()); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); String html = EntityUtils.toString(entity); System.out.println(html); } private void handleCookie(HttpPut httpget) throws Exception { String cookie = new LoginUtil().getCookieString(userName, pwd); httpget.setHeader("Cookie", cookie); }
以上是关于获取cookie后,使用cookie进行接下来的自动化操作的主要内容,如果未能解决你的问题,请参考以下文章