Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java-HtmlUnit对受限URI的访问被拒绝_Java_Htmlunit_Access Denied - Fatal编程技术网

Java-HtmlUnit对受限URI的访问被拒绝

Java-HtmlUnit对受限URI的访问被拒绝,java,htmlunit,access-denied,Java,Htmlunit,Access Denied,下面是我的代码 WebClient webClient = new WebClient(); HtmlPage page = webClient.getPage("http://www.cheapoair.com/"); String pageAsText = page.asText(); System.out.println(pageAsText); webClient.closeAllWindows(); 执行时会出现以下问

下面是我的代码

 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

我试过了,它对我有效

WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_6);

我认为这与“HTMLUnit访问受限URI被拒绝”无关,只是SetInnerHtmlAPI的问题。标题具有误导性,在搜索跨来源问题时会导致误报。