[img]https:// i.sstatic.net/0kSP3LsC.jpg[/img]
А вот фрагмент кода для взаимодействия с формой:
Код: Выделить всё
package org.example;
import org.htmlunit.BrowserVersion;
import org.htmlunit.WebClient;
import org.htmlunit.html.HtmlInput;
import org.htmlunit.html.HtmlPage;
import java.io.IOException;
public class LoginFormScraper {
public static void main(String[] args) throws IOException {
try (WebClient webClient = new WebClient(BrowserVersion.FIREFOX)) {
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setCssEnabled(false);
HtmlPage page = webClient.getPage("http://tplinkwifi.net/webpages/index.html#/login");
webClient.waitForBackgroundJavaScript(30 * 1000);
HtmlInput passwordInput = page.getFirstByXPath("//input[@type='password']");
if (passwordInput != null) {
passwordInput.setValue("foo");
// continue form scraping
} else {
System.out.println("No input element found!");
System.out.println("///////////////////////");
System.out.println(page.asXml());
}
}
}
}
Код: Выделить всё
No input element found!
///////////////////////
Opening...
//
Подробнее здесь: https://stackoverflow.com/questions/789 ... h-htmlunit