Perl 从 HTML 网页中解析出链接

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

use LWP::Simple;
use HTML::LinkExtor;

$html = get("http://www.oschina.net");

$link_extor = HTML::LinkExtor->new(\&handle_links);

$link_extor->parse($html);

sub handle_links
{
    ($tag, %links) = @_;

    if ($tag eq 'a') {

        foreach $key (keys %links) {

            if ($key eq 'href') {

                print "Found a hyperlink to $links{$key}.\n";

            }

        }
    }
}