#!/usr/bin/env perl use Mojo::UserAgent; use 5.016; use warnings; # Fetch website 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; my $res = $ua->get('1.weather.html')->result; # Visit all nodes recursively to extract more than just text for my $n ($res->dom->descendant_nodes->each) { # Text or CDATA node print $n->content; # Also include alternate text for images print $n->{alt} if $n->type eq 'tag' && $n->tag eq 'img'; }