简体   繁体   中英

JSOUP: How to get ID-s with different ending

I need to get HTML items with similar ID-s. The format of the ID is "yritusXXXX", where XXXX is four numbers that I do not know. Numbers do not increase or decrease, there is no system for them. So, how can I get all items with ID format "yritusXXXX" where X is random number?

Example code:

<div id="yritus7212" style="width:600px; font-size:13px; display: none;">

                    <div id="aeg">DATE<br />
                                  LOCATION</div>

                    <div id="pealk">HEADING</div>

                <div id="sisu"><p>And more text...</p>
<p>Some text...</p>
</div></div> 

您可以使用像这样的 css 通配符选择器

div[id^="yritus"]

If you need to use a single css style for all those ID's, you could use something like:

div[id^='yritus']{color: red};

If you need something else, than you should rephrase your question and be more specific on what your expected output should be.

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