#!/usr/bin/perl use Mojo::UserAgent; use Mojolicious::Lite; use Mojo::Util qw(encode); get '/' => sub { my $c = shift; 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 $site = 'https://www.fourmilab.ch/cgi-bin/Yoursky?z=1&lat=45.5183&ns=North&lon=122.676&ew=West'; my $ua = Mojo::UserAgent->new; $ua->max_redirects(5)->connect_timeout(20)->request_timeout(20); $ua->transactor->name($uaname); # get the table in question my $table_sel = 'center:nth-of-type(3)'; my $table = $ua->get( $site )->res->dom->at( $table_sel ); # fix links so they work $table->find('a')->each( sub { $_->attr( href => 'https://www.fourmilab.ch' . $_->attr->{'href'} ) } ); $c->res->headers->content_type('text/html, charset=iso-8859-1'); $c->render( data => encode(' iso-8859-1 ', $table ) ); }; app->start;