require HTML::HeadParser; $p = HTML::HeadParser->new; $p->parse($text) and print "not finished";
$p->header('Title') # to access <title>....</title> $p->header('Content-Base') # to access <base href="http://..."> $p->header('Foo') # to access <meta http-equiv="Foo" content="...">
parse()
and parse_file()
methods will return a
FALSE value as soon as a
<
BODY> element is found, and should not be called
again after this.
The HTML::HeadParser constructor takes an optional HTTP::Headers
object reference as argument. The parser will update this header object as
the various <
HEAD> elements are recognized. If no header is
given we will create an internal (and initially empty) header object. This
header object can be accessed with the header()
method.
The following header fields are initialized from elements found in the < HEAD> section of the HTML document:
$h = HTTP::Headers->new; $p = HTML::HeadParser->new($h); $p->parse(<<EOT); <title>Stupid example</title> <base href="http://www.sn.no/libwww-perl/"> Normal text starts here. EOT undef $p; print $h->title; # should print "Stupid example"
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.