【发布时间】:2022-01-30 18:30:18
【问题描述】:
我正在尝试使用 htmlunit 从 javascript 网站获取数据。目前,我只是尝试使用 webClient.getPage 调用该站点,这已经引发了异常。
public static void main(String[] args) throws Exception {
final WebClient webClient = new WebClient();
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.setJavaScriptTimeout(10000);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.getOptions().setTimeout(10000);
final HtmlPage page1 = webClient.getPage("[my-site-url-here]");
}
我收到以下异常:
======= EXCEPTION START ========
Exception class=[net.sourceforge.htmlunit.corejs.javascript.JavaScriptException]
com.gargoylesoftware.htmlunit.ScriptException: Error: [MobX] Proxy not available (https://[my-site-here]/static/js/8.107d4023.chunk.js#1)
从我的代码 sn-p 中可以看出,我已经应用了在其他线程中观察到的有关使用 htmlunit 时的 js 错误的选项。我没有使用代理,该网站使用的是 cloudflare。这可能是问题吗? 提前谢谢你。
【问题讨论】:
标签: javascript java selenium proxy htmlunit