I had tried Htmlunit but that doesn't work so can u help me with API or any other solution which I can study and get the solution.Thanku
import com.gargoylesoftware.htmlunit.BrowserVersion;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.List;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class GetPageSourceAfterJS {
public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException {
java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(java.util.logging.Level.OFF); /* comment out to turn off annoying htmlunit warnings */
WebClient webClient;
webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setJavaScriptEnabled(true);
//System.out.println("Loading page now: "+url);
HtmlPage page = webClient.getPage("http://www.thehindu.com/");
webClient.waitForBackgroundJavaScript(30 * 1000); /* will wait JavaScript to execute up to 30s */
String pageContent = page.asText();
System.out.println("pageContent");
//get divs which have a 'class' attribute of 'bucket'
// List<?> buckets = page.getByXPath("//div[@class='bucket']");
// System.out.println("Found "+buckets.size()+" 'bucket' divs.");
//System.out.println("#FULL source after JavaScript execution:\n "+pageAsXml);
}
} can u tell me why this failing to run