How can I get the href attribute from a dynamic link using java?

I am trying to fetch dynamic links from this site but have not been able to retrieve them.

But I retrieved links, i.e. static links successfully from this website

Sample code:

public class JavaScript {

    public static void main(String[] args) throws IOException {
        Document doc = Jsoup.connect("http://economictimes.indiatimes.com/archive.cms").get();
        Elements links = doc.select("a[href]");
        for (Element element : links) {
            System.out.println(element.attributes());
        }
    }
}

      

Now I want to fetch dynamic links from a website, that is, when we click on a date, it calls a function and generates a link. How can I get these links using JAVA?

+3


source to share


1 answer


Jsoup is an HTML parser. It doesn't support Javascript. Thus, it will not be able to run Javascript code that generates dynamic links.

Use one of the solutions below (to name a few) to achieve your goal:



0


source







All Articles