$ mojo get https://www.fourmilab.ch/yoursky/ '*' attr id skylat skynsn skynss skylon skyewe skyeww horlat hornsn hornss horlon horewe horeww feedback $ #### $ ./3.mo_scrape.pl ./3.mo_scrape.pl 45.5 -122.4 0.346 Can't call method "children" on an undefined value at ./3.mo_scrape.pl line 45. $ cat 3.mo_scrape.pl #!/usr/bin/env perl use Mojo::UserAgent; use 5.016; use warnings; use Mojo::UserAgent; use DateTime::Format::Strptime; use open ':std', OUT => ':utf8'; use Mojo::DOM; use Log::Log4perl; # get rid of old log my $file = '/home/hogan/Documents/hogan/logs/4.log4perl.txt'; unlink $file or warn "Could not unlink $file: $!"; my $log_conf4 = "/home/hogan/Documents/hogan/logs/conf_files/4.conf"; Log::Log4perl::init($log_conf4); #info my $logger = Log::Log4perl->get_logger(); $logger->info("$0"); ## important...no trailing zeroes else 301 error my $lat = 45.5; my $long = -122.4; my $elev = .346; #km $logger->info("$lat $long $elev"); my $guess = 2458960; #Earth day 2020 in julian days my $west_long = -$long; # the API docs says you must identify yourself, please make this something legit # my $name = '(example.com, contact@example.com)'; # can't I pretend to be a browser like any other? my $uaname = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36'; my $ua = Mojo::UserAgent->new; $ua->transactor->name($uaname); my $pturl = 'https://www.fourmilab.ch/yoursky/'; my $tx = $ua->post( $pturl => form => { skylat => $lat, skylon => $west_long } ); $tx = $ua->post( $pturl => form => { utc => $guess, date => '2' } ); my $sunrow = $tx->res->dom->at('center:nth-of-type(3) table tr:n./2th-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; $