??????????
????????????????https?????????????web???????????cookie??????????????????selenium??????selenium????????????????????????????htmlunit ????????????java ????????????????????????Ч?????htmlunit?????????????????????????????????У??????н???????????????????????????
???????Htmlunit???????
??????????Maven??????????????
????<dependency>
????<groupId>net.sourceforge.htmlunit</groupId>
????<artifactId>htmlunit</artifactId>
????<version>2.15</version>
????</dependency>
????<dependency>
???????Htmlunit???cookie??
final WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setUseInsecureSSL(true);
webClient.getOptions().setJavaScriptEnabled(false);
webClient.getOptions().setCssEnabled(false);
HtmlPage page = null;
page = webClient.getPage(loginUrl);
HtmlElement corpid = (HtmlElement) page.getElementById("id_corpid");
HtmlElement corppw = (HtmlElement) page.getElementById("id_corppw");
corpid.click();
String username = ph.readValue("userName");
corpid.type(username);
corppw.click();
String password = new String(dec.decodeBuffer(ph.readValue("password")));
corppw.type(password);
List<HtmlButton> loginBtn = (List<HtmlButton>) page.getByXPath("//div[@id='corp']/form/div[@class='span2 offset7 controls']/button");
Page resultPage = loginBtn.get(0).click();
String EHRCookie = HtmlUnitUtil.getCookieHeader(webClient);
logger.info("???openidpage cookie??? "+cookie);
return cookie;
??????л????????cookie?????????
????[INFO ]13:29:15??882??main??[Class]LoginUtil?? [Method]getEHRCookie?? ???openidpage cookie??? JSESSIONID=8A1979AC21C24DD8622E41D89ABFF6F3.classa-***.org-8010; sessionid=23d2b3e737c34cb8d8898bbec94c6a11
??????????Httpclient?м????????cookie????http????
????//????cookie
????httpGet.addHeader(new BasicHeader("Cookie"??cookie));
?????????????ù?????????????????????????н????????
???????
??????Https????????http??web??????????У??????Htmlunit??httpclient???????????????????????????в???????д??