[英]HtmlUnit and cookies
When I open the same site with Google Chrome on one side and HtmlUnit.WebClient(BrowserVersion.CHROME) on the other, I do not see the same cookies on both sides.当我在一侧使用 Google Chrome 打开同一个站点,在另一侧使用 HtmlUnit.WebClient(BrowserVersion.CHROME) 打开同一个站点时,我在两侧都看不到相同的 cookies。 Cookies are checked here with Google-Chrome-Dev.
Cookies 在此处使用 Google-Chrome-Dev 进行检查。 Nine cookies vs four cookies for the same site.
九个 cookies 与四个 cookies 用于同一站点。
The site is linckx.odoo.com .该网站是linckx.odoo.com 。
Is there something missing in my HtmlUnit code?我的 HtmlUnit 代码中是否缺少某些内容?
final WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setCssEnabled(false);
webClient.getCookieManager().setCookiesEnabled(true);
CookieManager cookieManager = webClient.getCookieManager();
final HtmlPage loginPage = webClient.getPage(url + "/en_US/web/login");
If i access the page https://linckx.odoo.com/en_US/web/login with a new browser (remove all cookies before) i get如果我使用新浏览器访问页面https://linckx.odoo.com/en_US/web/login (之前删除所有 cookies)我得到
nothing more.而已。 Maybe the differences are from other request you did in your browser before.
也许这些差异与您之前在浏览器中执行的其他请求不同。
new WebClient() in HtmlUnit is like starting a Browser with a complete new profile (all caches are empty, no cookies). HtmlUnit 中的 new WebClient() 就像使用一个完整的新配置文件启动一个浏览器(所有缓存都是空的,没有 cookie)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.