简体   繁体   English

如何使用HtmlUnit检查我是否登录了网站(例如LinkedIn)?

[英]How can I check if I logged in a website (e.g. LinkedIn) using HtmlUnit?

This is a newbie question in HtmlUnit. 这是HtmlUnit中的一个新手问题。 I have used the code I found on this question to log into LinkedIn, but when I open the page with Chrome the current user is logged out. 我已经使用我在此问题上找到的代码登录LinkedIn,但当我用Chrome打开页面时,当前用户已注销。 Can I check if I have indeed logged in the site? 我可以查看我是否确实已登录该站点?

In general the content of the page somehow changes, when you are logged in. So you could simply log the source of the page after you logged in. (If ajax is used on the page, you need to wait some time so that the javascript can modify the page) 一般情况下,当您登录时,页面的内容会以某种方式发生变化。因此您可以在登录后简单地记录页面的来源。(如果在页面上使用ajax,则需要等待一段时间才能使用javascript可以修改页面)

use the .toXml() -method to get the html source. 使用.toXml() - 方法获取html源代码。 You can also save this in a file egthtml and open it in a browser (active content and css will most probably not work, but you can still see enough in most cases to determine, if login worked or what is on the page after the login). 您也可以将其保存在egthtml文件中并在浏览器中打开(活动内容和CSS很可能无法正常工作,但在大多数情况下您仍然可以看到,如果登录有效或登录后页面上有什么内容)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查 Cloud Firestore 中任何文档的集合中是否存在值(例如名称)? - How can I check if a value e.g. name exists in a collection within any of documents in Cloud Firestore? 如何检查数组的所有元素是否不等于某个值? (例如,不是空的) - How can I check if all elements of array doesn't equal to some value? (e.g. not empty) 如何使用eclipse中编写的Java代码在远程桌面中导航(例如,打开Mozilla)? - How can i navigate (e.g. open Mozilla) in a Remote Desktop by using java code written in eclipse? 我可以使用java HtmlUnit库从linkedIn中提取信息吗? - Can I extract information from linkedIn using java HtmlUnit library? Selenium Webdriver:是否可以检查资源(例如XML文件)是否已加载? - Selenium webdriver: can I check if a resource (e.g. XML file) has been loaded? Java - 如何使用HtmlUnit登录网站? - Java – How can I Log into a Website with HtmlUnit? 使用Spring Security,我如何使用HTTP方法(例如GET,PUT,POST)来确定特定URL模式的安全性? - Using Spring Security, how can I use HTTP methods (e.g. GET, PUT, POST) to distingush security for particular URL patterns? 我如何从Locale.getISOCountries()获得“ en_US”; - How can I get e.g. “en_US” from Locale.getISOCountries(); 如何将JPEG压缩算法用于一维数据(例如一条线)? - How can I use JPEG Compression algorithm for 1D data (e.g. a line)? 我如何读取在KieSession外部插入的事实(例如规则结果)? - How can I read facts outside of the KieSession that were inserted inside of the KieSession­ (e.g. rules results)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM