Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Critique/Test my first module MetaParser

by tachyon (Chancellor)
on Nov 15, 2004 at 02:27 UTC ( [id://407754]=note: print w/replies, xml ) Need Help??


in reply to Critique/Test my first module MetaParser

As previously noted your parsing is broken. If you really want to use REs something like this is *less broken*

use LWP::Simple; use Data::Dumper; my $content = get('http://www.perlmonks.com') or die $!; $content =~ s/\s+/ /g; # condense whitespace (optional) my @meta = $content =~ m/<\s*meta([^>]+)>/gi; for ( @meta ) { m/name\s*=\s*"([^"]+)/i # double quotes || m/name\s*=\s*'([^']+)/i # single quotes || m/name\s*=\s*(\S+)/i # no quotes || m/http-equiv\s*=\s*"([^"]+)/i || m/http-equiv\s*=\s*'([^']+)/i || m/http-equiv\s*=\s*(\S+)/i || next; my $name = $1; m/content\s*=\s*"([^"]+)/i || m/content\s*=\s*'([^']+)/i || m/content\s*=\s*(\S+)/i || next; $meta{$name} = $1; } print Dumper \%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://407754]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-28 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found