简体   繁体   中英

JSoup extracting data from within paragraph

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM