in reply to Re^4: Running JavaScript from within Perl
in thread Running JavaScript from within Perl

OP wants to hit an endpoint, they don't have a file.
  • Comment on Re^5: Running JavaScript from within Perl

Replies are listed 'Best First'.
Re^6: Running JavaScript from within Perl
by bliako (Abbot) on Sep 17, 2019 at 11:01 UTC

    Thanks for pointing this out. The following code GETs the URL instead of reading contents from file. It can replace the file-reading section of my previous post:

    #use Encode; # used previously use LWP::UserAgent; my $ua = LWP::UserAgent->new(); my $URL = 'https://public-api.wordpress.com/rest/v1/read/feed/http%3A% +2F%2Fthe-art-of-autism.com%2Ffeed'; my $response = $ua->get($URL); die $response->status_line unless $response->is_success; my $contents = Encode::encode 'UTF-8', $response->decoded_content; ...

    All in all, Mojo::UserAgent solution by marto is more high-level. But I love plain LWP::UserAgent. Note: above can be made to authenticate and save cookies.