I have an html file that has this part:
<td> <a href="/romarin/detail.do?ID=0"> NAME </a> </td>
How can I open this link on href
with HtmlUnit?
My code:
final WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_11);
final HtmlPage page1 = webClient.getPage("file:\\" + newrfile);
final HtmlSubmitInput button = form.getInputByName("submit");
final HtmlPage page2 = button.click();
System.out.println(page2.asText());
final HtmlForm form2 = page2.getFormByName("SearchForm");
You can use getAnchorByHref:
HtmlAnchor htmlAnchor = page2.getAnchorByHref("/romarin/detail.do?ID=0");
Then you can click:
HtmlPage page3 = anchor.click();
Then you can save the page as a file:
page3.saveAs(some_file);
Or
System.out.println(page3.asXml());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With