AAA...">

How to create a Jsoup selector with AND operation?

I want to find the following tag in html.

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

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

Or is there a better way to do this? How regex? And How? Thanks!

+4
source share
1 answer

Just combine them into one 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 a regular expression does not make sense with such a world-class HTML parser.

+11
source

All Articles