in reply to Re: Having HTML::Parser problem
in thread Having HTML::Parser problem

I used to be a user of HTML::LinkExtor (I've never personally used HTML::LinkExtractor), but I've recently found HTML::SimpleLinkExtor, which works beautifully, and in less code. If you have to install a CPAN module, why not use one that gets your job done faster and easier!

Obligatory code (from one of my production projects):

sub extract_links { my $content = shift; my $extor = HTML::SimpleLinkExtor->new(); $extor->parse($content); my %seen; my @hrefs = grep { !$seen{$_}++} $extor->a; my @imgs = grep { !$seen{$_}++} $extor->img; my @fragments = grep {/#/} @hrefs; my @frag = map make_canon($_), @fragments; # Other magical stuff under here to turn relative # links from @imgs and @hrefs into absolute, using # the URI module, and some other hocus pocus. }