0

I'm using Jsoup to get content,DOM, CSS...so the problem is when I call an url with parameters , it gives always the content of the initial page because that page call an ajax query and I want to get the last content after the ajax execution.

This is my code :

 public String getContent(String link){
    String content=null;
    try{

        //Document doc = Jsoup.connect(link).userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36").timeout(10*1000).get();
        Document doc = Jsoup.connect(link).get();
        content =  doc.toString();
    }catch(IOException e){
        return "Invalid URL";
    }
    return content;
}

www.foo.com/page => initial Page

www.foo.com/page/aazere => Page with parameter

Help me please and thanks

James
  • 13
  • 3

1 Answers1

0

[…] because that page call an ajax query and I want to get the last content after the ajax execution.

Ajax execution isn't supported by Jsoup. But there's still a solution to this: Use a library (eg. HtmlUnit) to do the JS part and then parse the data with Jsoup.

For getting started:

Community
  • 1
  • 1
ollo
  • 24,797
  • 14
  • 106
  • 155