Hello i want to build an app with htmlunit for android (Android Studio). If I try to cget the page of youtube this tooks a lot of seconds (over 10). So that is too slow for user experience... other sites are slow too
build.gradle
implementation group: 'org.htmlunit', name: 'htmlunit3-android', version: '3.3.0'
my simple code
HtmlPage htmlPage;
try (WebClient webClient = new WebClient()) {
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setCssEnabled(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
htmlPage = webClient.getPage("https://www.youtube.com/");
} catch (MalformedURLException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
Possible duplicate of: HTMLUnit : super slow execution?
According to the accepted answer of the duplicate question, you can disable Javascript for faster execution
But if you need JavaScript to be enabled then you may try adding a timeout to request