Java – select “name” in jsoup
•
Java
I have multiple divs in the web page URL. I have to resolve that they have the same class name, but different names have no ID
For example
<div class="answer" style="display: block;" name="yyy" oldblock="block" jQuery1317140119108="11">
and
<div class="answer" style="display: block;" name="xxx" oldblock="block" jQuery1317140119108="11">
I want to select and parse data from only one div, that is, (name = "YYY") (the content in the div is < href > links, and each category is different
I looked up the selector syntax on the jsup web page, but I couldn't find a solution to the problem Can you help me solve this problem or let me know if I'm missing anything?
Solution
Use the [attributename = attributeevaluate] selector
Elements xxxDivs = document.select("div.answer[name=xxx]"); // ... Elements yyyDivs = document.select("div.answer[name=yyy]"); // ...
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码