How to take two attributes of the same HTML class with JSOUP - JAVA

Asked

Viewed 187 times

0

I’m taking content from an HTML page, I’m selecting content for a specific class, but in this case this class has content with a href and span, I can only take one.

Document doc = Jsoup.connect("https://www.sinonimos.com.br/"+texto+"/" ).get();   
Elements classHTML = doc.getElementsByClass("sinonimos").select("a[href]");

How I would filter to get the span also?

  • It is not clear what information you want to take. Give an example of the element and what you want to isolate from it (in both cases)

  • I was able to solve it. Elements classHTML = doc.getElementsByClass("synonyms"). select("a[href],span"); I only used "," to use more than one attribute.

  • It would be interesting to put an answer explaining what you did.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.