Re:pup: Parsing HTML at the Command Line
by turtlebits on Wednesday November 30, 2022 @02:14PM
(#33806007)
Will check it out, but would have preferred XPath selectors instead of CSS.
[ Parent
| on HN ]
Re:pup: Parsing HTML at the Command Line
by wmichelin on Wednesday November 30, 2022 @02:16PM
(#33806050)
Why? CSS selectors are the normal web developer way to select content from a document. Even JavaScript adopted the approach.
Re:pup: Parsing HTML at the Command Line
by tuukkah on Wednesday November 30, 2022 @03:30PM
(#33807188)
XPath supports more complex queries. In JavaScript, XPath is available as document.evaluate
Re:pup: Parsing HTML at the Command Line
by undume on Wednesday November 30, 2022 @03:08PM
(#33806886)
xmllint can do that:
curl example.org | xmllint --html --xpath '//some/xpath/selector' -
Re:pup: Parsing HTML at the Command Line
by jwilk on Thursday December 01, 2022 @06:32AM
(#33814969)
Only if it's good old HTML 4. libxml2's parser doesn't grok HTML 5.
Re:pup: Parsing HTML at the Command Line
by BossHogg on Wednesday November 30, 2022 @03:56PM
(#33807553)
There's also https://github.com/charmparticle/xpe
Re:pup: Parsing HTML at the Command Line
by curben on Wednesday November 30, 2022 @05:24PM
(#33808765)
I'm using xmlstarlet in Alpine as a bare minimum way to scrap a webpage in CI pipeline.
Re:pup: Parsing HTML at the Command Line
by ludovicianul on Thursday December 01, 2022 @07:28AM
(#33815348)
This has support for both XPath and CSS selectors: https://github.com/ludovicianul/hq