使用以下代码
在HtmlUnit中加载链接:http://pdfcast.org/login webclient = new WebClient(BrowserVersion.CHROME_16);
webclient.setJavaScriptEnabled(true);
webclient.getCookieManager().setCookiesEnabled(true);
webclient.setThrowExceptionOnScriptError(false);
webclient.setRefreshHandler(new ThreadedRefreshHandler());
HtmlPage currentPage = webclient.getPage("http://pdfcast.org/login");
发生错误:
Sep 26, 2012 10:04:38 PM com.gargoylesoftware.htmlunit.html.HtmlPage loadExternalJavaScriptFile
SEVERE: Error loading JavaScript from [http://www.google-analytics.com/ga.js].
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 504 Gateway Time-out for http://www.google-analytics.com/ga.js
at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:542)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1041)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:981)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:366)
at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:234)
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:244)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:607)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:329)
这个问题有解决办法吗?
答案 0 :(得分:0)
适用于htmlunit 2.13
import java.io.IOException;
import java.net.MalformedURLException;
import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.ThreadedRefreshHandler;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class KUKU {
public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException {
WebClient webclient = new WebClient(BrowserVersion.CHROME_16);
webclient.getOptions().setJavaScriptEnabled(true);
webclient.getCookieManager().setCookiesEnabled(true);
webclient.getOptions().setThrowExceptionOnScriptError(false);
webclient.setRefreshHandler(new ThreadedRefreshHandler());
HtmlPage currentPage = webclient.getPage("http://pdfcast.org/login");
System.out.println(currentPage.asText());
}
}
这是输出
07/11/2013 14:53:33 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型:'text / javascript'。 07/11/2013 14:53:34 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型: '应用程序/ x-的javascript'。 07/11/2013 14:53:34 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型:'text / javascript'。 07/11/2013 14:53:35 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型:'text / javascript'。 07/11/2013 14:53:35 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型: '应用程序/ x-的javascript'。 07/11/2013 14:53:36 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型:'text / javascript'。 07/11/2013 14:53:36 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型:'text / javascript'。 07/11/2013 14:53:36 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型:'text / javascript'。 07/11/2013 14:53:36 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型:'text / javascript'。 07/11/2013 14:53:37 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型: '应用程序/ x-的javascript'。 07/11/2013 14:53:37 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型:'text / javascript'。 07/11/2013 14:53:37 com.gargoylesoftware.htmlunit.DefaultCssErrorHandler错误警告: CSS错误: 'http://pdfcast-data.appspot.com/css/style_fb_bt_apl_star.min.css?1' [251:69]表达式错误。 (无效的令牌“。”。期待一个 of ,,,,,,,,“ - ”, “=”,“)”。)07/11/2013 14:53:37 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型: '应用程序/ x-的javascript'。 07/11/2013 14:53:38 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 警告:遇到过时的内容类型: '应用程序/ x-的javascript'。登录和注册搜索上传PDF 常问问题。联系我们Facebook Connect Google登录登录注册登录 如果您已拥有PDFCast帐户,则可以在下面登录。用户名 密码登录忘记密码?注册没有帐户 然而?立即注册填写以下表格。用户名密码
重复密码电子邮件输入上面的字词(重新加载图片)
注册第三方您可以使用Facebook或Google登录 帐户。它更容易,更安全。点击下面的徽标。
浏览| DMCA指南|使用条款|隐私声明|联系| Facebook©版权所有2013 PDFCast.org
0.0255 - 4.11MB
顺便说一句: 不推荐使用BrowserVersion.CHROME_16。 请改用BrowserVersion.CHROME