I’ve been using Mojolicious quite a bit this year, and I love it.
Recently I completed a project for a client using Mojo::UserAgent as a server to write a simple monitoring dashboard. But this week I’ve been using the command line ‘mojo’ tool to grab some stock prices from the web. And it’s brilliant how simple it is.
Here’s how to grab AAPL from Google Finance, outputting the current price:
mojo get https://www.google.com/finance/quote/SPY:NYSEARCA ".fxKbKc" text
Working out the CSS selectors is simply a case of looking at the web page in your browser using the debug tools to look through the source. I’ve also found this resource on CSS selectors handy, as I don’t do this every day I’m prone to forgetting the syntax.
Nearly 11 years later, in 2023, I discovered xq 🤣 You know what’s even simpler than mojo? This:
curl -L https://www.google.com/finance/quote/SPY:NYSEARCA | xq -q ".fxKbKc"