File 使用htmlunit下载excel文件
我正在尝试使用Htmlunit从网站下载xls文件。当我点击链接下载文件时,我会看到一个javascript确认框 我尝试了多个选项,但找不到该选项:File 使用htmlunit下载excel文件,file,download,htmlunit,window.location,File,Download,Htmlunit,Window.location,我正在尝试使用Htmlunit从网站下载xls文件。当我点击链接下载文件时,我会看到一个javascript确认框 我尝试了多个选项,但找不到该选项: ConfirmHandler okHandler = new ConfirmHandler(){ @Override public boolean handleConfirm(Page arg0, String arg1) {
ConfirmHandler okHandler = new ConfirmHandler(){
@Override
public boolean handleConfirm(Page arg0, String arg1) {
// TODO Auto-generated method stub
return true;
}
};
webClient.setConfirmHandler(okHandler);
也试过了
final String page = currentPage.getElementById("downloadExcel").click().getWebResponse().getContentAsString();
String buttonJavaScript = "window.location='...........'";
ScriptResult result = page.executeJavaScript(buttonJavaScript);
webClient.waitForBackgroundJavaScript(1000);
如果有人能提出解决方案,这将是非常有帮助的。
请用URL发布完整的案例,以便其他人可以复制这个问题。例如,考虑这个URL:点击这里,所有文件都被直接下载,但在我的例子中,我使用window.location获得下载窗口,我不知道如何使用htmlunit处理这个问题。