{"id":6810,"date":"2022-12-20T19:33:40","date_gmt":"2022-12-20T22:33:40","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/htmlheadparser-man3\/"},"modified":"2022-12-20T19:33:40","modified_gmt":"2022-12-20T22:33:40","slug":"htmlheadparser-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/htmlheadparser-man3\/","title":{"rendered":"HTML::HeadParser (man3)"},"content":{"rendered":"<h1 align=\"center\">HTML::HeadParser<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#METHODS\">METHODS<\/a><br \/> <a href=\"#EXAMPLE\">EXAMPLE<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">HTML::HeadParser \u2212 Parse <HEAD> section of a HTML document<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">require HTML::HeadParser; <br \/> $p = HTML::HeadParser\u2212>new; <br \/> $p\u2212>parse($text) and print &#8220;not finished&#8221;; <br \/> $p\u2212>header(&#8216;Title&#8217;) # to access <title>&#8230;.<\/title> <br \/> $p\u2212>header(&#8216;Content\u2212Base&#8217;) # to access <base href=\"http:\/\/...\"> <br \/> $p\u2212>header(&#8216;Foo&#8217;) # to access <meta http\u2212equiv=\"Foo\" content=\"...\"> <br \/> $p\u2212>header(&#8216;X\u2212Meta\u2212Author&#8217;) # to access <meta name=\"author\" content=\"...\"> <br \/> $p\u2212>header(&#8216;X\u2212Meta\u2212Charset&#8217;) # to access <meta charset=\"...\"><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The &#8220;HTML::HeadParser&#8221; is a specialized (and lightweight) &#8220;HTML::Parser&#8221; that will only parse the < <small>HEAD<\/small> >&#8230;<\/HEAD> section of an <small>HTML<\/small> document. The <b>parse()<\/b> method will return a <small>FALSE<\/small> value as soon as some < <small>BODY<\/small> > element or body text are found, and should not be called again after this.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that the &#8220;HTML::HeadParser&#8221; might get confused if raw undecoded <small>UTF\u22128<\/small> is passed to the <b>parse()<\/b> method. Make sure the strings are properly decoded before passing them on.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The &#8220;HTML::HeadParser&#8221; keeps a reference to a header object, and the parser will update this header object as the various elements of the < <small>HEAD<\/small> > section of the <small>HTML<\/small> document are recognized. The following header fields are affected: <br \/> Content-Base:<\/p>\n<p style=\"margin-left:17%;\">The <i>Content-Base<\/i> header is initialized from the <base href=\"...\"> element.<\/p>\n<p style=\"margin-left:11%;\">Title:<\/p>\n<p style=\"margin-left:17%;\">The <i>Title<\/i> header is initialized from the <title>&#8230;<\/title> element.<\/p>\n<p style=\"margin-left:11%;\">Isindex:<\/p>\n<p style=\"margin-left:17%;\">The <i>Isindex<\/i> header will be added if there is a <isindex> element in the <head>. The header value is initialized from the <i>prompt<\/i> attribute if it is present. If no <i>prompt<\/i> attribute is given it will have \u2019?\u2019 as the value.<\/p>\n<p style=\"margin-left:11%;\">X\u2212Meta-Foo:<\/p>\n<p style=\"margin-left:17%;\">All <meta> elements containing a &#8220;name&#8221; attribute will result in headers using the prefix &#8220;X\u2212Meta\u2212&#8221; appended with the value of the &#8220;name&#8221; attribute as the name of the header, and the value of the &#8220;content&#8221; attribute as the pushed header value.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><meta> elements containing a &#8220;http\u2212equiv&#8221; attribute will result in headers as in above, but without the &#8220;X\u2212Meta\u2212&#8221; prefix in the header name.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><meta> elements containing a &#8220;charset&#8221; attribute will result in an &#8220;X\u2212Meta\u2212Charset&#8221; header, using the value of the &#8220;charset&#8221; attribute as the pushed header value.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The \u2019:\u2019 character can\u2019t be represented in header field names, so if the meta element contains this char it\u2019s substituted with \u2019\u2212\u2019 before forming the field name.<\/p>\n<h2>METHODS <a name=\"METHODS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following methods (in addition to those provided by the superclass) are available: <br \/> $hp = HTML::HeadParser\u2212>new <br \/> $hp = HTML::HeadParser\u2212>new( $header )<\/p>\n<p style=\"margin-left:17%;\">The object constructor. The optional $header argument should be a reference to an object that implement the <b>header()<\/b> and <b>push_header()<\/b> methods as defined by the &#8220;HTTP::Headers&#8221; class. Normally it will be of some class that is a or delegates to the &#8220;HTTP::Headers&#8221; class.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">If no $header is given &#8220;HTML::HeadParser&#8221; will create an &#8220;HTTP::Headers&#8221; object by itself (initially empty).<\/p>\n<p style=\"margin-left:11%;\">$hp\u2212>header;<\/p>\n<p style=\"margin-left:17%;\">Returns a reference to the header object.<\/p>\n<p style=\"margin-left:11%;\">$hp\u2212>header( $key )<\/p>\n<p style=\"margin-left:17%;\">Returns a header value. It is just a shorter way to write &#8220;$hp\u2212>header\u2212>header($key)&#8221;.<\/p>\n<h2>EXAMPLE <a name=\"EXAMPLE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">$h = HTTP::Headers\u2212>new; <br \/> $p = HTML::HeadParser\u2212>new($h); <br \/> $p\u2212>parse(<<EOT); <br \/> <title>Stupid example<\/title> <br \/> <base href=\"http:\/\/www.linpro.no\/lwp\/\"> <br \/> Normal text starts here. <br \/> EOT <br \/> undef $p; <br \/> print $h\u2212>title; # should print &#8220;Stupid example&#8221;<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">HTML::Parser, HTTP::Headers<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The &#8220;HTTP::Headers&#8221; class is distributed as part of the <i>libwww-perl<\/i> package. If you don\u2019t have that distribution installed you need to provide the $header argument to the &#8220;HTML::HeadParser&#8221; constructor with your own object that implements the documented protocol.<\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Copyright 1996\u22122001 Gisle Aas. All rights reserved.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This library is free software; you can redistribute it and\/or modify it under the same terms as Perl itself.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  HTML::HeadParser \u2212 Parse  section of a HTML document <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3177,3007],"class_list":["post-6810","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-htmlheadparser","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6810"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6810\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}