Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > HTML::Parser

Thread Tools


Posts: n/a

"Bart Lateur" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Zebee Johnstone wrote:
> >Are there any tutorials or explanations of HTML:arser?
> >
> >I've read the perldoc and I don't understand it. It's gibberish to me.

> The best intro on the subject, IMO, is gellyfish's old tutorial.
> <>
> Now, if after going through this, you decide that callback-oriented
> programming isn't your cup of tea, you might also want to take a look at
> the alternative approach, token stream oriented: using HTML::TokeParser,
> or a bit more high-level: HTML::TokeParser::Simple. There, you read
> tokens (a tag, a piece of plain text) from a HML source one at a time,
> like lines from a file.
> --
> Bart.

HTML::TokeParser doc has an example:
"This example 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:

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";

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off