I had been using www::mechanize::firefox to extract hidden html from a javascript heavy website but mozrepl no longer works for more recent versions of firefox
I thought I could use www::mechanize::phantomjs in a similar way but I'm struggling to get it to find the elements and extract the inner html from xpath
The long xpath in the code below should be getting all the html in:
<div class="tn-napsTable">
This same code worked well in mechanize::firefox but when i run it with PhantomJS I get the error message 'no elements found'. Any help would be much appreciated!
use strict; use WWW::Mechanize::PhantomJS; use Data::Dumper; my $mech = WWW::Mechanize::PhantomJS->new( launch_arg => ['ghostdriver/src/main.js' ], ); $mech->get('https://www.racingpost.com/tipping/naps-table/'); sleep 5; my $cont= $mech->xpath('/html/body/div[4]/main/div/div[2]/div/div/div[ +2]/div/div[1]/div[1]/div[2]', one => 1,synchronize=>1); my $content=$cont->{innerHTML}; print $content;
In reply to No Elements Found with WWW::Mechanize::PhantomJS by rmperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |