用perl提取HTML 网页内容

评论2,632

利用LWP::Simple模块,提取网页源代码,赋值给一个字符串变量,然后再进行后续分析,比如部分文件的提取等等:

[code lang="perl"]
use LWP::Simple qw(get);
my $html = get( "http://www.example.com/index.html" );
[/code]

另外可以把网页源代码下载下载,直接存为一个文件:

[code lang="perl"]
use LWP::Simple qw(getstore);
getstore( "http://www.example.com/index.html", "foo.html" );
[/code]

发表评论

匿名网友