in reply to Re^2: File::Fetch fetch to scalar
in thread File::Fetch fetch to scalar
You could start by checking the MIME type:
#!/usr/bin/env perl use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my @urls = ( 'https://jsonplaceholder.typicode.com/todos/1', 'https://www.perl.org/' ); for my $url (@urls) { my $res = $ua->get ($url); print index($res->header('Content-Type'), 'application/json') > -1 + ? "$url is JSON\n" : "$url is not JSON\n"; }
🦛
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: File::Fetch fetch to scalar
by Anonymous Monk on Jul 03, 2021 at 09:46 UTC |