Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Critique/Test my first module MetaParser

by tachyon (Chancellor)
on Nov 15, 2004 at 01:51 UTC ( #407753=note: print w/replies, xml ) Need Help??


in reply to Critique/Test my first module MetaParser

Your parsing is very broken. You are making a whole load of invalid assumptions about the structure of a meta tag. You don't have to look very far for common examples of HTML syntax that breaks your parser. Perlmonks for example has meta tags. Your code does not extract them...... Please learn to use HTML::Parser or learn a lot more about what is and is not valid HTML.

use LWP::Simple; use HTML::Parser; use Data::Dumper; my $data = get('http://www.spydersubmission.com'); my $p = HTML::Parser->new( api_version => 3, start_h => [ \&start, "self,tagname,attr" ], ); sub start { my ( $self, $tagname, $attr ) = @_; return unless $tagname eq 'meta'; my $name = $attr->{name} || $attr->{'http-equiv'} || undef; return unless defined $name; $self->{meta}->{$name} = $attr->{content} || 'NULL'; } $p->parse($data); $p->eof; print Dumper $p->{meta};

cheers

tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://407753]
help
Chatterbox?
and monks are getting baked in the sun...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2018-07-23 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (465 votes). Check out past polls.

    Notices?