in reply to extracting link *and* tag content from "a href"

This example from the documentation for HTML::TokeParser:

use HTML::TokeParser; $p = HTML::TokeParser->new(shift||"index.html"); while (my $token = $p->get_tag("a")) { my $url = $token->[1]{href} || "-"; my $text = $p->get_trimmed_text("/a"); print "$url\t$text\n"; }

And what it does is, "...extracts all links from a document. It will print one line for each link, containing the URL and the textual description between the <A>...</A> tags..."


Dave

Replies are listed 'Best First'.
Re^2: extracting link *and* tag content from "a href"
by hmerrill (Friar) on Jul 19, 2004 at 19:09 UTC
    Thanks - that's exactly what I need.