Download file using HtmlUnit

后端 未结 6 1936
一生所求
一生所求 2021-02-05 23:17

I am trying to download xls file for a website. When I click the link to download the file, I get a javascript confirm box. I handle it like below

    ConfirmHan         


        
6条回答
  •  不知归路
    2021-02-05 23:46

    I found a way to get InputStream using WebWindowListener. Inside of webWindowContentChanged(WebWindowEvent event), I put code below.

    InputStream xls = event.getWebWindow().getEnclosedPage().getWebResponse().getContentAsStream();
    

    After I get xls, I could save the file into my hard disk.

提交回复
热议问题