使用perl获取网页联接
时间:2005-05-07 来源:yzjboy
#!/usr/bin/perl
##获取网页联接
##by yzjboy
use LWP::Simple;
use HTML::LinkExtor;
$html = get("http://www.sina.com.cn");
$link_extor = HTML::LinkExtor->new(&handle_links);
$link_extor->parse($html);
print "Content-type: text/html ";
sub handle_links
{
($tag, %links) = @_;
if ($tag eq 'a') {
foreach $key (keys %links) {
if ($key eq 'href') {
print "FOUND A hypelink to $links{$key}. ";
}
}
}
}
相关阅读 更多 +
排行榜 更多 +