Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Critique/Test my first module MetaParser

by tachyon (Chancellor)
on Nov 15, 2004 at 01:51 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://407753]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-24 03:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found