rmperl has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: No Elements Found with WWW::Mechanize::PhantomJS
by Corion (Patriarch) on Jun 03, 2018 at 07:16 UTC | |
by rmperl (Novice) on Jun 04, 2018 at 10:36 UTC | |
by Corion (Patriarch) on Jun 04, 2018 at 10:50 UTC | |
by Corion (Patriarch) on Jun 04, 2018 at 18:46 UTC | |
by rmperl (Novice) on Jun 08, 2018 at 12:24 UTC |