Hacker News new | ask | show | jobs
by gcr 3139 days ago
With a domain-specific tool, it's even easier though.

    curl ... | jq -r .last
1 comments

Sure. But you can't use jq to scrape arbitrary websites, for example. :)
Jeff Atwood has an entertaining post about parsing HTML with regular expressions:

https://blog.codinghorror.com/parsing-html-the-cthulhu-way/

“”” That's right, if you attempt to parse HTML with regular expressions, you're succumbing to the temptations of the dark god Cthulhu's … er … code. “””

Let's not forget about this masterpiece: https://stackoverflow.com/a/1732454/864310
Indeed, its quality cannot be ignored and must be shared; it’s referenced in the Atwood post.
Parsing and scraping are different things though. You don't need to parse a web page to extract specific things from it.
Of course, if it's anything like HTML, the formatting will vary over time that you really want a more permissive parser like BeautifulSoup. I haven't found a cli interface, so I briefly wrote my own ages ago: https://github.com/jldugger/dotfiles/blob/master/bin/select.....
For cases where a website is not a tutorial for websites, regex is a suitable tool for scraping.