阿帕奇.....的HtmlUnit问题,在处理JavaScript [英] apache HTMLUNIT..... PROBLEM in handling javascript

查看:160
本文介绍了阿帕奇.....的HtmlUnit问题,在处理JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 http://www.orkut.com ) >

com.gargoylesoftware.htmlunit.WebClient

但是,当我点击提交按钮,它不带我到预期的页面应该登录后。相反,它再次返回同一个登录页面。在意识清晰,存在一些登录问题。当我尝试在同一code。与站点doen't了JavaScript,它工作正常,所以我想我不能够处理脚本。

But when I click on the "Submit" button, it doesn't take me to the expected page that should come after login. Instead it returns the same login page again. In clear sense, there is some problem in login. When I try the same code with sites that doen't have javascript, it works fine so I think I am not able to handle scripts.

我使用的是follwoing code尝试:

I am trying using the follwoing code:

public static void main(String[] args) {
    final WebClient webClient = new WebClient();
    try {
        HtmlPage loginPage = webClient.getPage(new URL("https://www.google.com/accounts/ServiceLogin?service=orkut&hl=en-US&rm=false&continue=http%3A%2F%2Fwww.orkut.com%2FRedirLogin%3Fmsg%3D0%26page%3Dhttp%253A%252F%252Fwww.orkut.co.in%252FHome.aspx&cd=IN&passive=true&skipvpage=true&sendvemail=false"));
        System.out.println(loginPage.getTextContent());
        List<HtmlForm> forms = loginPage.getForms();
        HtmlForm loginForm = forms.get(0);
        HtmlInput username = loginForm.getInputByName("Email");
        HtmlInput password = loginForm.getInputByName("Passwd");
        HtmlInput submit = loginForm.getInputByName("signIn");
        username.setNodeValue("username");
        password.setNodeValue("password");
        HtmlPage homePage = submit.click();
        Thread.sleep(10 * 1000);
        System.out.println(homePage.getTextContent());
    }catch(Exception ex) {
        ex.printStackTrace();
    }
}

当我们点击提交按钮,在实际它调用第一此功能

When we do click on the "submit" button, in actual it calls first this function

onsubmit="return(gaia_onLoginSubmit());"

<form id="gaia_loginform" action="https://www.google.com/accounts/ServiceLoginAuth?service=orkut" method="post"
    onsubmit="return(gaia_onLoginSubmit());">

谁能帮我在这。

请注意:我将支付解决方案

NOTE: I WILL PAY FOR THE SOLUTION

推荐答案

根据他们的网站 JavaScript的支持是由 Mozilla的犀牛提供的,也许你需要的是将其添加到您的类路径(和也许有些配置捣鼓)。

According to their site the JavaScript support is provided by Mozilla Rhino, so maybe all you need is to add it to your classpath (and perhaps fiddle with some configurations).

此外,HtmlUnit的专业支持

Also, HtmlUnit has professional support

这篇关于阿帕奇.....的HtmlUnit问题,在处理JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆