使用HTMLUnit以编程方式使用Java登录Facebook

使用HTMLUnit以编程方式使用Java登录Facebook,java,javascript,html,facebook,login-script,Java,Javascript,Html,Facebook,Login Script,这个问题是对这个问题的补充: 我已经使用(稍微修改过的版本)以下代码登录到其他网站的帐户 WebClient webClient = new WebClient(); HtmlPage page1 = webClient.getPage("http://www.facebook.com"); HtmlForm form = page1.getForms().get(0); HtmlSubmitInput button = (HtmlSubmitInput) form.getInputsByVa

这个问题是对这个问题的补充:

我已经使用(稍微修改过的版本)以下代码登录到其他网站的帐户

WebClient webClient = new WebClient();
HtmlPage page1 = webClient.getPage("http://www.facebook.com");
HtmlForm form = page1.getForms().get(0);
HtmlSubmitInput button = (HtmlSubmitInput) form.getInputsByValue("Login").get(0);
HtmlTextInput textField = form.getInputByName("email");
textField.setValueAttribute("bob@smith.com");
HtmlPasswordInput textField2 = form.getInputByName("pass");
textField2.setValueAttribute("ladeeda");
HtmlPage page2 = button.click();
然而,每当我尝试使用正确的电子邮件和密码登录facebook时,我都会遇到两个问题:

SEVERE: Job run failed with unexpected RuntimeException: TypeError: Cannot find 
function addImport in object [object]. 
(http://static.ak.fbcdn.net/rsrc.php/yC/r/gmR3y_ARtaM.js#10)

Exception class=[com.gargoylesoftware.htmlunit.ScriptException]
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "length"         
from undefined (http://static.ak.fbcdn.net/rsrc.php/yC/r/gmR3y_ARtaM.js#10)

我做错了什么?

它看起来像HTMLUN它不喜欢某些javascript

尝试将其关闭,因为登录时不需要:

webClient.setJavaScriptEnabled(false);

我尝试过这个,但无法登录facebook。我得到
page2
as。如果我启用javascript,那么我会得到警告
WARN:(HtmlScript.java:472):脚本不是javascript(类型:application/ld+json,语言:)。正在跳过执行。
以及其他警告和错误。在en中,我得到
page2
as。你能看看我的问题吗?