A
A
A1994Y2020-05-13 13:17:05
Java
A1994Y, 2020-05-13 13:17:05

Parse HTML tag when tag id changes?

Hello everyone, the question is that there is a "comment-id-******" tag, and instead of asterisks, the id of the comment, so I need to parse all the comments, I won't write for each comment:
PS there are a lot of comments to do it manually do and id are always different.

Element commentElem1 = doc.select(".comment-id-556412");
Element commentElem2 = doc.select(".comment-id-123123");
Element commentElem3 = doc.select(".comment-id-313213");

It may be necessary as a regular program or how to check these tags.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
edward_freedom, 2020-05-13
@A1994Y

Try this
doc.select("[class^=comment-id]");

[attr^=value], [attr$=value], [attr*=value]: elements with attributes that start with, end with, or contain the value, eg [href*=/path/]

https://jsoup.org/cookbook/extracting-data/selecto...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question