Question

I want to extract all the text there is between all paragraphs on an unknown site (meaning i do not know the structure of the site).

So far i've got:

        Elements paragraphEmail = doc.select("p");

Where doc = Jsoup.connect(url).get();

        for (Element e : paragraphEmail) {

            }   

How to achieve this?

Was it helpful?

Solution

doc.select("p") will give you all the paragraph elements as a collection Elements.

Use a for each loop to get the text:

for(Element e : paragraphEmail){
    System.out.println(e.text());
}

I suggest you take a look at the Jsoup cookbook and the API reference to get more familiar with the methods in Jsoup.

Cookbook API Reference

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top