2 # A helper class for getting values out of a HTML document
5 package videosite::HTMLHelper;
8 @ISA = qw(HTML::TreeBuilder);
12 use LWP::Simple qw(!get);
16 my $self = $class->SUPER::new(@_);
18 return bless($self, $class);
26 unless(defined($c = LWP::Simple::get($URL))) {
39 my ($tagname, $classifier);
43 # Try to make sense of the path specifier.
44 # For the moment, we just allow paths of the following two forms:
47 # b) <tagname>[@<attribute>=<value> (, @<attribute>=<value> ...)]
50 unless (($tagname, $classifier) = $path =~
51 m|(\w+)(?:\[((?:\@[\w-]+=\x22[^\x22]+?\x22)(?:\s*,\s*(?:\@\w+=\x22[^\x22]+?\x22))*)\])?|) {
53 return wantarray?():undef;
56 $matchtag{'_tag'} = $tagname;
57 if (defined($classifier)) {
58 foreach (split(/\s*,\s*/, $classifier)) {
59 my ($n, $v) = split(/=/, $_, 2);
66 return $self->look_down(%matchtag);