开发者

How to create an Jsoup Selector with an AND operation?

开发者 https://www.devze.com 2023-04-07 22:39 出处:网络
I want to find the following tag in a html. <a href=\"http://www.google.com/AAA\" class=\"link\">AAA</a>

I want to find the following tag in a html.

<a href="http://www.google.com/AAA" class="link">AAA</a>

I know I can use a selector like a[href^=http://www.google.com/] or a[class=link]. But how can I combine this two conditions?

Or is there a better wa开发者_C百科y to do this? Like regex? and how? Thanks!


Just combine them in a single CSS selector.

Elements links = document.select("a[href^=http://www.google.com/][class=link]");
// ...

or

Elements links = document.select("a.link[href^=http://www.google.com/]");
// ...

Considering regex makes no sense with such a world class HTML parser.

0

精彩评论

暂无评论...
验证码 换一张
取 消