in reply to Quick 'n dirty extraction of JSON from an HTML page

Another approach, given that you mention invalid JSON, is to dump a JS object from the JS side via Selemnium's JavascriptExecutor(). I can offer a rough untested sketch only, 1) load the page, 2) wait for a few seconds, 3) tell Selenium driver to execute console.log(JSON.stringify(opportunity));

A similar way is via WWW::Mechanize::PhantomJS. From its doc:

use WWW::Mechanize::PhantomJS; my $mech = WWW::Mechanize::PhantomJS->new(); $mech->get('http://google.com'); # give it some time... $mech->eval_in_page('console.log(JSON.stringify(opportunity));');

Bummer! I have just realised that var opportunity is local to the anonymous function. I guess there is no other way (from the JS side) than injecting a console.log() within the renderer function but I don't know how unless executing JS locally which opens a new can of warms. But if you do find a way with this approach you will not need to parse the DOM. You will have JSON. That's why I leave my comment.

bw, bliako