JSOUP:如何获得具有不同结尾的ID-s

时间:2022-08-22 20:31:30

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?

我需要获得具有类似ID-s的HTML项目。 ID的格式是“yritusXXXX”,其中XXXX是我不知道的四个数字。数字不增加或减少,没有系统。那么,我怎样才能获得ID格式为“yritusXXXX”的所有项目,其中X是随机数?

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> 

2 个解决方案

#1


1  

you can use a css wildcard selector like this

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

div[id^="yritus"]

#2


0  

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

如果你需要为所有这些ID使用单一的CSS样式,你可以使用类似的东西:

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.

如果你需要别的东西,那么你应该重新解释你的问题,并更具体地说明你的预期产出应该是什么。

#1


1  

you can use a css wildcard selector like this

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

div[id^="yritus"]

#2


0  

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

如果你需要为所有这些ID使用单一的CSS样式,你可以使用类似的东西:

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.

如果你需要别的东西,那么你应该重新解释你的问题,并更具体地说明你的预期产出应该是什么。