热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

HtmlUnit请求页面抛出异常

谢谢你查看我的问题

谢谢你查看我的问题



用htmlunit请求页面时失败
"http://passport2.chaoxing.com/login?fid=&refer="
用谷歌浏览器访问却正常
用htmlunit2.3和htmlunit2.27都是这样

麻烦能够帮我找一下原因吗



代码:
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) {

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
        webClient.setJavascriptTimeout(5000);

        webClient.getOptions().setDoNotTrackEnabled(false);

        webClient.getOptions().setUseInsecureSSL(true);//接受任何主机连接 无论是否有有效证书

        webClient.getOptions().setCssEnabled(false);

        webClient.getOptions().setJavascriptEnabled(true);

        webClient.getOptions().setThrowExceptionOnScriptError(false);

        webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);

        webClient.getOptions().setTimeout(100000);//设置连接超时时间

        webClient.getCOOKIEManager().setCOOKIEsEnabled(true);

        webClient.setAjaxController(new NicelyResynchronizingAjaxController());//很重要,设置支持AJAX

        System.out.println("js enabled:" + webClient.getOptions().isJavascriptEnabled());



        System.out.println("css enabled:" + webClient.getOptions().isCssEnabled());

        HtmlPage page;

        page = webClient.getPage("http://passport2.chaoxing.com/login?fid=&refer=");

        sleep(15000);

        ps.print(page.asXml());

        ;

    } catch (MalformedURLException e) {

        e.printStackTrace();

    } catch (IOException e) {

        e.printStackTrace();

    } catch (InterruptedException e) {

        e.printStackTrace();

    }

报错信息:
"C:Program Files (x86)Javajdk1.8.0_112binjava" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:IntelliJ IDEA 2017.3.4libidea_rt.jar=23768:D:IntelliJ IDEA 2017.3.4bin" -Dfile.encoding=UTF-8 -classpath "D:IntelliJ IDEA 2017.3.4libidea_rt.jar;D:IntelliJ IDEA 2017.3.4pluginsjunitlibjunit-rt.jar;D:IntelliJ IDEA 2017.3.4pluginsjunitlibjunit5-rt.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibcharsets.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibdeploy.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextaccess-bridge-32.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextcldrdata.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextdnsns.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextjaccess.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextjfxrt.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextlocaledata.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextnashorn.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextsunec.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextsunjce_provider.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextsunmscapi.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextsunpkcs11.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibextzipfs.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibjavaws.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibjce.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibjfr.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibjfxswt.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibjsse.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibmanagement-agent.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibplugin.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibresources.jar;C:Program Files (x86)Javajdk1.8.0_112jrelibrt.jar;D:projectWebBrowseroutproductionWebBrowser;D:资源hamcrest-core-1.1.jar;D:资源hamcrest-library-1.1.jar;D:资源junit-4.11.jar;D:资源htmlunit-2.27libsac-1.3.jar;D:资源htmlunit-2.27libxalan-2.7.2.jar;D:资源htmlunit-2.27libhtmlunit-2.27.jar;D:资源htmlunit-2.27libcommons-io-2.5.jar;D:资源htmlunit-2.27libhttpcore-4.4.6.jar;D:资源htmlunit-2.27libhttpmime-4.5.3.jar;D:资源htmlunit-2.27libxml-apis-1.4.01.jar;D:资源htmlunit-2.27libcssparser-0.9.23.jar;D:资源htmlunit-2.27libhttpclient-4.5.3.jar;D:资源htmlunit-2.27libserializer-2.7.2.jar;D:资源htmlunit-2.27libcommons-codec-1.9.jar;D:资源htmlunit-2.27libcommons-lang3-3.5.jar;D:资源htmlunit-2.27libxercesImpl-2.11.0.jar;D:资源htmlunit-2.27libneko-htmlunit-2.27.jar;D:资源htmlunit-2.27libcommons-logging-1.2.jar;D:资源htmlunit-2.27libhtmlunit-core-js-2.27.jar;D:资源htmlunit-2.27libjetty-io-9.4.5.v20170502.jar;D:资源htmlunit-2.27libjetty-http-9.4.5.v20170502.jar;D:资源htmlunit-2.27libjetty-util-9.4.5.v20170502.jar;D:资源htmlunit-2.27libjetty-client-9.4.5.v20170502.jar;D:资源htmlunit-2.27libwebsocket-api-9.4.5.v20170502.jar;D:资源htmlunit-2.27libwebsocket-client-9.4.5.v20170502.jar;D:资源htmlunit-2.27libwebsocket-common-9.4.5.v20170502.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 Main.MainClass,Chaoxing
js enabled:true
css enabled:false
五月 11, 2018 9:13:12 下午 com.gargoylesoftware.htmlunit.Javascript.StrictErrorReporter runtimeError
严重: runtimeError: message=[An invalid or illegal selector was specified (selector: '*,:x' error: Invalid selector: :x).] sourceName=[http://passport2.chaoxing.com...] line=[2] lineSource=[null] lineOffset=[0]
五月 11, 2018 9:13:12 下午 com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController processSynchron
信息: Re-synchronized call to http://passport2.chaoxing.com...

java.lang.StackOverflowError

1
2
3
4
5
6
at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transformCompilationUnit_r(NodeTransformer.java:412)

at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transformCompilationUnit_r(NodeTransformer.java:412)

at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transformCompilationUnit_r(NodeTransformer.java:412)

at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transformCompilationUnit_r(NodeTransformer.java:412)

at

                             ...

net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transformCompilationUnit_r(NodeTransformer.java:412)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transformCompilationUnit_r(NodeTransformer.java:412)

at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transformCompilationUnit_r(NodeTransformer.java:412)

at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transformCompilationUnit_r(NodeTransformer.java:412)

at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transformCompilationUnit_r(NodeTransformer.java:412)

at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transformCompilationUnit(NodeTransformer.java:56)

at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transform(NodeTransformer.java:32)

at net.sourceforge.htmlunit.corejs.Javascript.NodeTransformer.transform(NodeTransformer.java:35)

at net.sourceforge.htmlunit.corejs.Javascript.CodeGenerator.compile(CodeGenerator.java:60)

at net.sourceforge.htmlunit.corejs.Javascript.Interpreter.compile(Interpreter.java:189)

at net.sourceforge.htmlunit.corejs.Javascript.Context.compileImpl(Context.java:2698)

at net.sourceforge.htmlunit.corejs.Javascript.Context.compileString(Context.java:1632)

at com.gargoylesoftware.htmlunit.Javascript.HtmlUnitContextFactory$TimeoutContext.compileString(HtmlUnitContextFactory.java:214)

at net.sourceforge.htmlunit.corejs.Javascript.Context.compileString(Context.java:1624)

at com.gargoylesoftware.htmlunit.Javascript.JavascriptEngine$2.doRun(JavascriptEngine.java:716)

at com.gargoylesoftware.htmlunit.Javascript.JavascriptEngine$HtmlUnitContextAction.run(JavascriptEngine.java:879)

at net.sourceforge.htmlunit.corejs.Javascript.Context.call(Context.java:637)

at net.sourceforge.htmlunit.corejs.Javascript.ContextFactory.call(ContextFactory.java:518)

at com.gargoylesoftware.htmlunit.Javascript.JavascriptEngine.compile(JavascriptEngine.java:725)

at com.gargoylesoftware.htmlunit.Javascript.JavascriptEngine.compile(JavascriptEngine.java:691)

at com.gargoylesoftware.htmlunit.Javascript.JavascriptEngine.execute(JavascriptEngine.java:737)

at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavascript(HtmlPage.java:918)

at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:317)

at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:382)

at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:247)

at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:268)

at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:800)

at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)

at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:756)

at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1236)

at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1136)

at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:226)

at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:345)

at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3178)

at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2141)

at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:945)

at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:521)

at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:472)

at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)

at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:999)

at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:250)

at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:192)

at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:272)

at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:160)

at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:522)

at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:396)

at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:313)

at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:461)

at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:446)

at Main.MainClass.Chaoxing(MainClass.java:100)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)

at org.junit.runners.ParentRunner.run(ParentRunner.java:309)

at org.junit.runner.JUnitCore.run(JUnitCore.java:160)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)

at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Process finished with exit code -1


   



推荐阅读
  • 本文介绍了SIP(Session Initiation Protocol,会话发起协议)的基本概念、功能、消息格式及其实现机制。SIP是一种在IP网络上用于建立、管理和终止多媒体通信会话的应用层协议。 ... [详细]
  • 本文由chszs撰写,详细介绍了Apache Mina框架的核心开发流程及自定义协议处理方法。文章涵盖从创建IoService实例到协议编解码的具体步骤,适合希望深入了解Mina框架应用的开发者。 ... [详细]
  • 本文介绍了一种在 Android 开发中动态修改 strings.xml 文件中字符串值的有效方法。通过使用占位符,开发者可以在运行时根据需要填充具体的值,从而提高应用的灵活性和可维护性。 ... [详细]
  • 本文探讨了在AspNetForums平台中实施基于角色的权限控制系统的方法,旨在为不同级别的用户提供合适的访问权限,确保系统的安全性和可用性。 ... [详细]
  • 汇总了2023年7月7日最新的网络安全新闻和技术更新,包括最新的漏洞披露、工具发布及安全事件。 ... [详细]
  • 本文介绍了Tomcat的基本操作,包括启动、关闭及首次访问的方法,并详细讲解了如何在IDEA中创建Web项目,配置Servlet及其映射,以及如何将项目部署到Tomcat。 ... [详细]
  • 本文探讨了使用Python实现监控信息收集的方法,涵盖从基础的日志记录到复杂的系统运维解决方案,旨在帮助开发者和运维人员提升工作效率。 ... [详细]
  • Beetl是一款先进的Java模板引擎,以其丰富的功能、直观的语法、卓越的性能和易于维护的特点著称。它不仅适用于高响应需求的大型网站,也适合功能复杂的CMS管理系统,提供了一种全新的模板开发体验。 ... [详细]
  • 本文将从基础概念入手,详细探讨SpringMVC框架中DispatcherServlet如何通过HandlerMapping进行请求分发,以及其背后的源码实现细节。 ... [详细]
  • importjava.io.*;importjava.util.*;publicclass五子棋游戏{staticintm1;staticintn1;staticfinalintS ... [详细]
  • 本文详细介绍了 Java 中 org.w3c.dom.Node 类的 isEqualNode() 方法的功能、参数及返回值,并通过多个实际代码示例来展示其具体应用。此方法用于检测两个节点是否相等,而不仅仅是判断它们是否为同一个对象。 ... [详细]
  • 本文介绍了如何通过安装和配置php_uploadprogress扩展来实现文件上传时的进度条显示功能。通过一个简单的示例,详细解释了从安装扩展到编写具体代码的全过程。 ... [详细]
  • 本文探讨为何Request对象的外观设计被认为是精妙的,重点在于其如何利用门面模式确保数据安全,同时保持系统的高效交互。 ... [详细]
  • C/C++ 应用程序的安装与卸载解决方案
    本文介绍了如何使用Inno Setup来创建C/C++应用程序的安装程序,包括自动检测并安装所需的运行库,确保应用能够顺利安装和卸载。 ... [详细]
  • 本文基于Java官方文档进行了适当修改,旨在介绍如何实现一个能够同时处理多个客户端请求的服务端程序。在前文中,我们探讨了单客户端访问的服务端实现,而本篇将深入讲解多客户端环境下的服务端设计与实现。 ... [详细]
author-avatar
cc
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有