quinta-feira, 23 de maio de 2019

Download file using htmlunit

// Exemplo de como baixar um arquivo após clicar em um link com HtmlUnit - Java

WebClient webClient = new WebClient();
try {
    HtmlPage page = webClient.getPage("https://cdn.kernel.org");
    List anchors = page.getByXPath("//*[@id='latest_link']/a");
    anchors.get(0).click();
    InputStream is = page.getEnclosingWindow().getEnclosedPage().getWebResponse().getContentAsStream();
    String file = "public/kernel.tar.xz";
    Files.copy(is, Paths.get(file));
    File f = new File(file);
} catch (IOException e) {
    e.printStackTrace();
}

Nenhum comentário:

How to Enable Click to Minimize On Ubuntu

Open a terminal using Ctrl+Alt+T shortcut or searching for it in the menu. All you need is to copy paste the command below in the terminal: ...