in reply to Re: Get data from javascript
in thread Get data from javascript

The url in the JS is fixed per page, so one per page. I parse lots of pages and want to extract the URL. I tried the code you gave
my $wanted = $page =~ /push_delayed_image\(([^,]+)/; print Dumper $wanted;
But this prints $VAR - 1; not the URL

Replies are listed 'Best First'.
Re^3: Get data from javascript
by choroba (Cardinal) on Jul 11, 2016 at 15:11 UTC
    You need list context to get the capture groups back.

    my ($wanted) = $page =~ /push_delayed_image\(([^,]+)/; # ^ ^

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re^3: Get data from javascript
by RonW (Parson) on Jul 11, 2016 at 16:39 UTC

    Alternately to what Choroba said, you could:

    $page =~ /push_delayed_image\(([^,]+)/; my $wanted = $1;

    Often, I'm using a conditional, so will do this:

    if ($page =~ /push_delayed_image\(([^,]+)/) { my $wanted = $1; ... }