How to select by a property?
Thanks for making this package. It does work easily using selectors but I don't understand what's a simple way to select a node by node name and attribute (jQuery style), e.g.
<meta property="og:title" content="Apple iPad mini 4 128Gb WiFi+4G Gold (MK782)">
I tried parsed.querySelectorAll('meta[property="og:title"]') but it retuens empty result.
Property selector is not supported, as it will affect performance dramatically.
Note: only tagName, #id, .class selectors supported. And not behave the same as standard querySelectorAll() as it will stop searching sub tree after find a match.
Thanks for reply. I think it would not be bad even if it was affecting performance (optional use -- optional performance decrease). Anyway, I picked https://github.com/cheeriojs/cheerio as it does support properties.
+1, I have several use cases where attribute query is not required, but there are a few which I really need, making it optional seems good to me.
It's possible to write a custom query function. The main reason for not supporting this natively is that this requires parsing attributes before querying, which slows everything down, and there are many different matching methods for attributes (eg. ~= and ^=).
I do agree with @ashi009 . but sometimes we indeed need the attribute query, i suggest maybe we could parse some attibutes user given when they call the parse method, not all the attributes. == and != will be good for me. If people do not care about the time the parsing method taken, just use cheerio will be fine.