sub pullpage { my ($text) = @_; if ($text =~ m!(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])! ) { # grab the link parts my $text_uri = "$1://$2$3"; # put the link back together Irssi::print "$text_uri"; my $cua = LWP::UserAgent->new( protocols_allowed => ['http', 'https'], timeout => 5, ); $cua->agent( 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.59' ); # so we look like a real browser $cua->max_size( 4000 ); my $cres = $cua->get(URI::->new($text_uri)); if ($cres->is_success) { my $page_body = untag(encode('utf-8', $cres->decoded_content())); # we get an error unless this is utf8 $page_body =~ s/\s+/ /g; return $page_body; } } else { return undef } }