#!/usr/bin/perl use strict; use warnings; use feature 'say'; use Mojo::UserAgent; use DateTime::Format::Strptime; use open ':std', OUT => ':utf8'; my $url = 'https://api.weather.gov/stations/KPDX/observations/latest'; # the API docs says you must identify yourself, please make this something legit my $name = '(example.com, contact@example.com)'; my $ua = Mojo::UserAgent->new; $ua->transactor->name( $name ); # get JSON response my $json = $ua->get( $url )->res->json->{properties}; # for each cloud.... foreach my $cloud ( @{$json->{cloudLayers}} ){ say "$cloud->{amount}, $cloud->{base}{value}"; } # JD from JSON timestamp my $format = DateTime::Format::Strptime->new( pattern => '%FT%T%z'); my $dt = $format->parse_datetime( $json->{timestamp} ); say 'Julian Day: ' . $dt->jd; my $pturl = 'http://www.fourmilab.ch/cgi-bin/Yoursky?z=1&lat=45.5183&ns=North&lon=122.676&ew=West'; # you wanted Julian date so it looks like date should be '2' from the source. my $tx = $ua->post( $pturl => form => { utc => $dt->jd, date => '2' } ); my $sunrow = $tx->res->dom->at('center:nth-of-type(3) table tr:nth-of-type(3)'); # output say 'Name:' . $sunrow->children->[0]->all_text; say 'Altitude: ' . $sunrow->children->[4]->text; say 'Azimuth: ' . $sunrow->children->[5]->text; say 'Visible: ' . $sunrow->children->[6]->text;