I discovered pQuery the other day, and had been meaning to try it out.
I got the chance to use it today, and I have to say, I’m impressed. I am, however, rather wary that the last release was nearly two years ago; I’m not sure I’d want to use it in production code unless it’s being actively maintained – I might use it for non-important things before making that call.
Anyway, a brief example:
Let’s say you want to capture the content of a paragraph/div with the class “bar” from a page somewhere.. it can be as simple as:
pQuery('http://www.example.com/foo.html')->find('.bar')->html;
Let’s say you want to extract all H1 headings instead:
pQuery($url)
->find('h1')
->each(
sub { say "Heading: " . pQuery($_)->text; }
);
I’d love to see this continue in active development – there’s several features it could really use, but what’s already there is handy stuff!
If you liked that post, then try these...
Easy profiling for Dancer apps
WordPress plugin for easy CPAN module links