Re: HTML::Element::extract_links() vs. LinkExtor

Boris Statnikov (boris@blaze.cs.jhu.edu)
Sun, 12 Apr 1998 15:31:10 -0400 (EDT)


Can LinkExtor extract links - yes; text of those links - no: at least,
that's how I understand Gisle's response to my original question.

Boris


Too many cooks spoil the brouhaha.

	Harvard Lampoon, "Bored of The Rings"


On 12 Apr 1998, Gisle Aas wrote:

> Otis Gospodnetic <otis@populus.net> writes:
> 
> > but can LinkExtor extract links if I, somehow, supply it the content of an
> > HTML page (a string with page's HTML in it)?
> > I know I can do this:
> > 
> >     my $parsed_html = HTML::Parse::parse_html($webdoc->content);  // can I
> > just have a a string with HTML of a page in it in place of $webdoc->content
> > ?
> >     for (@{ $parsed_html->extract_links(qw (a))})
> >     {
> >         my ($link) = $_->[0];
> >         ....
> >     }
> > 
> > but I'm not sure if I can do the equivalent with LinkExtor...
> > would this be the same thing:
> > 
> >     foreach (HTML::LinkExtor->new->parse($webdoc->content)->eof->links)
> >  // can I just have a a string with HTML of a page in it in place of
> > $webdoc->content ?
> 
> as far as I can see, it should work.
> 
> Regards,
> Gisle
> 
> 
> >         my($tag, %links) = @$_;
> >         next unless $tag eq "a";
> >         foreach $link (values %links) {
> >             ....
> >         }
> >     }
> 
>