19

Web サイトをトラバースしようとしていますが、ページの 1 つで次のエラーが発生します。

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)

このエラーを無視できる方法はありますか? カレンダーが正しく読み込まれるかどうかは特に気にしません。

4

3 に答える 3

33

Alexey の答えは HttpUnit に対するものです。HtmlUnit の場合、コードは似ています

WebClient client = new WebClient();
client.getOptions().setThrowExceptionOnScriptError(false);
于 2014-08-31T11:31:38.833 に答える
0

HttpUnitOptionsクラスの次のメソッドを使用できます。

//change the scriptingEnabled flag
static void setScriptingEnabled(boolean scriptingEnabled)

// Determines whether script errors result in exceptions or warning messages.
static void setExceptionsThrownOnScriptError(boolean throwExceptions)

または、try-catch ブロックで問題領域を囲みます -

try {
   // code with error

}catch(e) {
   // handle error
}
于 2014-01-22T22:35:46.217 に答える