0

我正在使用 HtmlUnit 连接到网站 X,
在其代码中,站点 X 调用站点 Y,
由于防火墙,站点 Y 无法访问,返回 401 Unauthorized 错误,
=> 整个调用WebClient.getPage()失败并显示FailingHttpStatusCodeException.

即使没有来自 Y 的东西,有没有办法忽略 401 错误并加载页面 X?
我的代码中已经有了webClient.setThrowExceptionOnFailingStatusCode(false);

4

1 回答 1

0

In my case it turned out website Y was called by javascript, as I didn't need js on that page doing webClient.setJavaScriptEnabled(false); fixed the problem.

However I still feel like HtmlUnit error reporting should be a bit more smart then: throw exception vs do nothing.

于 2012-10-09T11:19:38.873 回答