-1

以下是我的代码

 WebClient webClient = new WebClient();
        HtmlPage page = webClient.getPage("http://www.cheapoair.com/");
        String pageAsText = page.asText();
        System.out.println(pageAsText);
        webClient.closeAllWindows();

当我执行它时,会出现以下问题:

Caused by: net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: Access to restricted URI denied (script in http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com/cheapoair&layout=button_count&show_faces=true&width=80&action=like&font=arial&colorscheme=light&height=21 from (109, 78) to (109, 2233)#109)
    at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.runtimeError(StrictErrorReporter.java:81)
    at net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:983)
    at net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:1039)
    at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.open(XMLHttpRequest.java:455)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:137)
    at net.sourceforge.htmlunit.corejs.javascript.FunctionObject.call(FunctionObject.java:452)
    at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1473)
    at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:815)
    at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:123)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:539)
    at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:651)
    ... 90 more
Enclosed exception: 
java.lang.RuntimeException: Exception invoking setInnerHTML
4

1 回答 1

0

我试过了,它对我有用

WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_6);
于 2012-12-27T20:16:09.703 回答