- 網站的 JavaScript 在解析過程有錯誤。
- 網頁本身失連、或者網頁內的任一連結(包含 JavaScript 檔、CSS 檔、圖片等外部連結)失連。
如果想要讓 HtmlUnit 略過這些錯誤時,可以參考 [1] 的方法
對 HtmlUnit 設定忽略即可。
1 2 3 4 5 6 7 |
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38) : // Ignore the HTTP status code and script error. webClient.getOptions().setJavaScriptEnabled( true ); webClient.getOptions().setThrowExceptionOnFailingStatusCode( false ); webClient.getOptions().setThrowExceptionOnScriptError( false ); // Reduce the error logs showed by HtmlUnit. webClient.getOptions().setPrintContentOnFailingStatusCode( false ); |
參考資料:
沒有留言:
張貼留言