HtmlUnit and JavaScript in links

前端 未结 1 858
猫巷女王i
猫巷女王i 2021-01-23 15:49

Copied from here:

I need to save files from websites using HtmlUnit. I am currently navigating to pages that have several anchors that use javascript:

 o         


        
1条回答
  •  南笙
    南笙 (楼主)
    2021-01-23 16:19

    It's more simple than that. Just simulate the click event and then get the WebResponse:

    HtmlElement anchorAttachment = (HtmlElement) pageETrackerItem.getByXPath(".../a").get(0);
    
    InputStream is = anchorAttachment.click().getWebResponse().getContentAsStream();
    

    0 讨论(0)
提交回复
热议问题