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.

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/AAPL:NASDAQ ".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.

Simples.