我试图通过一个网站,但在他的一个页面上,我得到这个错误:
EcmaError: lineNumber=[671] column=[0] lineSource=[null] name=[TypeError] sourceName=[https://reservations.besodelsolresort.com/asp/CalendarPopup.js] message=[TypeError: Cannot read property "parentNode" from undefined (https://reservations.besodelsolresort.com/asp/CalendarPopup.js#671)] com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "parentNode" from undefined (https://reservations.besodelsolresort.com/asp/CalendarPopup.js#671)
有没有反正我可以忽略这个错误?我不是特别关心日历是否正确加载.
解决方法
Alexey的答案是针对HttpUnit.对于HtmlUnit,代码是类似的
WebClient client = new WebClient(); client.getOptions().setThrowExceptionOnScriptError(false);