Just to show you how darn easy, accurate, deep, and fast some of this is with XML::LibXML...
#!/usr/bin/perl use strict; use warnings; use XML::LibXML; # This is a shortcut, see the docs for more formal usage. my $doc = XML::LibXML->new->parse_html_fh(*DATA); my $root = $doc->getDocumentElement; my ( $head ) = $root->findnodes("head"); my ( $body ) = $root->findnodes("body"); print "Head stuff...\n"; for my $refresh ( $head->findnodes('meta[@http-equiv]') ) { print "\t", $refresh->getAttribute("content"), "\n"; } print "\nBody stuff...\n"; for my $link ( $body->findnodes('a[@href]') ) { printf("%25s --> %s\n", $link->textContent || $link->getAttribute("title") || "n/a" +, $link->getAttribute("href") ); } # print $doc->serialize(1); __DATA__ PUT YOUR HTML DOCUMENT DOWN HERE. Took it out for space.
Reproducing the same output/report format you want is left as an excercise for the reader. :) The docs for the family of modules are terse but quite good once you see the big picture. There are options to allow more liberal/broken HTML to be parsed (or attempted anyway).
In reply to Re: HTML::Parser fun
by Your Mother
in thread HTML::Parser fun
by FreakyGreenLeaky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |