gpt4 book ai didi

java - 服务器信息未更新

转载 作者:行者123 更新时间:2023-12-01 11:15:07 25 4
gpt4 key购买 nike

我一直在几个网站上测试 HtmlUnit;在所有这些网站中,他们都有元素,例如单选按钮或复选框,当您单击时,您的该网站上的个人资料已更新;您无需提交表格或任何事物。但是当我对 HtmlUnit 采取完全相同的操作时,我的个人资料服务器上并没有真正更新。我需要做一些特别的事情吗例如将 HtmlUnit 拥有的页面的本地副本与服务器以便服务器看到更改?作为示例,我添加了我的用于在私有(private)/公共(public)和副网站上切换我的简历的代码反之亦然。当我在浏览器上访问该页面时,我所要做的就是单击一个使简历公开/私有(private)的两个单选按钮;但当我这样做时在HtmlUnit上也是如此,然后去浏览器访问页面查看,可以看到服务器上的信息没有改变。我有下面包括我的代码。请注意,我有另一种登录方法该网站,并且我知道我登录正确。鉴于这种情况正在发生对于我的网站,我想也许有一些类似与服务器同步的事情我没有做。

========================================

    public void update(String urlOfThePage)
{
// First, declare any element name or xapth that you are going to
use. String xpathOfIsPublicRadioButton = "//input[@id='privacy_show']";
String xpathOfIsPrivateRadioButton = "//input[@id='privacy_hide']";

// Get the first page
try
{
final HtmlPage resumePage = (HtmlPage) webclient.getPage(urlOfThePage);
CrawlerUtility.savePage(resumePage, "resumePage");
final HtmlRadioButtonInput makePublicRadioButton =
(HtmlRadioButtonInput)

resumePage.getFirstByXPath(xpathOfIsPublicRadioButton);
final HtmlRadioButtonInput makePrivateRadioButton =
(HtmlRadioButtonInput)
resumePage.getFirstByXPath(xpathOfIsPrivateRadioButton);
Page result = null;
if (isProfilePublic())
{
result = makePrivateRadioButton.click();
System.out.println("The Profile is changed to private
now.");
Thread.sleep(60000);
}
else
{
result = makePublicRadioButton.click();
System.out.println("The Profile is changed to public now.");
Thread.sleep(60000);
}

}
catch (Throwable e)
{
e.printStackTrace();
}//End of try/catch block.


}//End of update().

最佳答案

如果您不提交表单,那么您可能在幕后使用 AJAX 向服务器发送数据。 HTML 单元不会将其发送到服务器,因为它不会处理 AJAX 请求。您需要的是更复杂的东西,例如 Sikuli http://www.sikuli.org它实际上以与用户完全相同的方式点击网页上的元素。您还可以尝试特定于网络浏览器的 Selenium ( http://www.seleniumhq.org/ )。

关于java - 服务器信息未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31925776/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com