The simplicity of Perl Mojolicious for web get extractions

· 1 minute read

I’ve been using Mojolicious quite a bit this year, and I love it.

I’ve done a project for a client using Mojo::UserAgent, and used it 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 and the percentage change:

mojo get ".pr > #ref_22144_l, .ch > #ref_22144_cp text"

Working out the CSS selectors is simply a case of looking at the web page in, say, Chrome, and using the debug tools to look through the source. Simples.