EDITED to add: this has been solved. Thanks so much.
I'm a perl novice who wants to learn just enough perl to get by without putting much effort into it.
Please tell me how to read the JSON object returned by
obtained fromhttp://web.archive.org/cdx/search/cdx?url=archive.org&output=json&limi +t=3
https://github.com/internetarchive/wayback/tree/master/wayback-cdx-ser +ver#output-format-json
CLARIFICATION ADDED: Below is an example json object. I want to assign a variable $first_timestamp to the first timestamp (19970126045828).
[["urlkey","timestamp","original","mimetype","statuscode","digest","le +ngth"], ["org,archive)/", "19970126045828", "http://www.archive.org:80/", "te +xt/html", "200", "Q4YULN754FHV2U6Q5JUT6Q2P57WEWNNY", "1415"], ["org,archive)/", "19971011050034", "http://www.archive.org:80/", "te +xt/html", "200", "XAHDNHZ5P3GSSSNJ3DMEOJF7BMCCPZR3", "1402"], ["org,archive)/", "19971211122953", "http://www.archive.org:80/", "te +xt/html", "200", "XAHDNHZ5P3GSSSNJ3DMEOJF7BMCCPZR3", "1405"]]
How do I do that?
Context:
I currently have the following working code:
use strict; use warnings; use Mojo::UserAgent; use LWP::UserAgent; use HTTP::Request::Common qw(GET); my $outputFilename = "test_output.txt"; my $fh_data; my $name; open( $fh_data, '>', $outputFilename ) or die "Could not open file '$outputFilename' $!"; my $url = "https://public-api.wordpress.com/rest/v1/read/feed/?url=anautismobser +ver.wordpress.com"; my $ua = Mojo::UserAgent->new; my $json = $ua->get($url)->res->json; for my $feedurl ( @{ $json->{feeds} } ) { if ( $feedurl->{meta}{links}{site} ) { my $siteurl2 = $feedurl->{meta}{links}{site}; my $ua2 = Mojo::UserAgent->new; my $json3 = $ua2->get($siteurl2)->res->json; $name = $json3->{name}; print $fh_data "$name"; } } close $fh_data;
I want to modify the code to read the JSON object returned if I set
my $url = http://web.archive.org/cdx/search/cdx?url=archive.org&output +=json&limit=3
and I want to write the timestamps into a text file.
Thank you.
In reply to reading a JSON object by anautismobserver
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |