Htmlq: like jq, but for html
141–150 of 172 posts
Re: Htmlq: like jq, but for html
#142Earlier quoted context omitted.
xmlstarlet is really nothing like jq, as a language. But yes, I use it because it is the best commandline xml processor I'd found. That's the only similarity to jq. Is this the yq? https://kislyuk.github.io/yq/ It does contain an 'xq', as a literal wrapper for jq, piping output into it after transcoding XML to JSON using xmltodict https://github.com/martinblech/xmltodict (which explodes xml into separate JSON data st…
Thank you for the comments. I've only recently discovered both tools, and literally used them once each. Of the two `xq` was easier for my particular work case (parsing a Magento config) but I keep both tools in my virtual toolbox. If you have any other suggestions for parsing XML for exploratory purposes I'm very happy to hear them.
Just installed xq. It's nice just seeing the pretty-printed json output, so thanks for the pointer. Probably better than xmlstarlet for my usage, which just queries and outputs text, not xml. hmmm, that's probably true for most commandline uses...
Re: Htmlq: like jq, but for html
#143Re: Htmlq: like jq, but for html
#144Once upon a time I was using pup[0] for such thing as well as later I changed to cascadia[1] which seemed much more advanced. Comparing the two repos, it seems pup is dead, but cascadia may not be. These tools, including htmlq, seem to sell themselves as "jq for html", which is far from the truth. Jq is closer to the awk where you can do just about everything with json. Cascadia, htmlq, and pup seem closer to grep fo…
Re: Htmlq: like jq, but for html
#145Re: Htmlq: like jq, but for html
#146Earlier quoted context omitted.
I'd like to add my support here too, but with a note. When scraping and parsing (or writing integration test DSL), I always start out with CSS selectors. But always hit cases where they lack or require hoop-jumping and then fall back on Xpath. I then have a codebase with both CSS-Sel and Xpath, which is arguably worse then having only one method. I suspect here, one uses this tool untill CSS selector limitations are…
Do you mind giving an example? I'm having trouble following where CSS is limited for selection.
E.g. when you have a list of numbers on the website, XPath can calculate the sum or the maximum of the numbers
Or you have a list of names "Last name, First name", then you can remove the last name and sort the first names alphabetically. Or count how often each name occurs and return the most popular name.
Then it goes back to selection, e.g. select all numbers that are smaller than the average. Or calculate the most popular name, then select all elements containing that name
Re: Htmlq: like jq, but for html
#147Earlier quoted context omitted.
"htmlq is like jq but for html" is a very specific 'dog whistle' for people who use jq. I agree that people who don't know what jq is will get no value and pay no attention. But for people who use jq, the claim is, like a dog whistle, clear, concise, and means exactly what it says. In two seconds, everyone using both jq and html will instantly know what is available and log it away. So for general purposes, it's a te…
I can't speak for people who don't know jq, but knowing jq, this is a great tagline: it gives me an immediate understanding of what it does, how I could expect to use it and what value and ease of use I can expect. I'll be trying it out next time I'm on a PC.
I can, and it's not illuminating at all.
Re: Htmlq: like jq, but for html
#148Re: Htmlq: like jq, but for html
#149Earlier quoted context omitted.
Do you mind giving an example? I'm having trouble following where CSS is limited for selection.
Well, the big one is selecting a parent from the child.
Looks like that psuedo-class has not been implemented in the kuchiki library that htmlq uses though.
Re: Htmlq: like jq, but for html
#150Earlier quoted context omitted.
I'd like to add my support here too, but with a note. When scraping and parsing (or writing integration test DSL), I always start out with CSS selectors. But always hit cases where they lack or require hoop-jumping and then fall back on Xpath. I then have a codebase with both CSS-Sel and Xpath, which is arguably worse then having only one method. I suspect here, one uses this tool untill CSS selector limitations are…
Do you mind giving an example? I'm having trouble following where CSS is limited for selection.