通过Perl的URI模块过滤URL可以获得什么?

前端之家收集整理的这篇文章主要介绍了通过Perl的URI模块过滤URL可以获得什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我像这样转换我的$url时,我能获得一些东西:$url = URI-> new($url)?

#!/usr/bin/env perl
use warnings; use strict;
use 5.012;
use URI;
use XML::LibXML;

my $url = 'https://stackoverflow.com/';
$url = URI->new( $url );

my $doc = XML::LibXML->load_html( location => $url,recover => 2 );
my @nodes = $doc->getElementsByTagName( 'a' );
say scalar @nodes;

解决方法

URI module constructor会为您清理URI – 例如正确地转义URI构造无效的字符(参见 URI::Escape).

猜你在找的Perl相关文章