CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...: Re: [Regent] Trying to get meta tags: Edit Log



zOrK
Novice

Jul 26, 2007, 11:09 PM


Views: 2690
Re: [Regent] Trying to get meta tags

try

Code
#!/usr/bin/perl 
use strict;
use HTML::TokeParser;

sub get_description {
my $content;
my $p = HTML::TokeParser->new($_[0]);
while ( my $tag = $p->get_tag("meta") ) {
if ( defined( $tag->[1]{'name'} )) {
if($tag->[1]{'name'} eq "description") {
$content = $tag->[1]{'content'}
}
};
}
print "$content\n";
}

get_description("index.html");


You need http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/HTML-Parser-3.56.tar.gz

---------

You may also find Perl information on my blog: http://www.ferry.cl/carlos/

(This post was edited by zOrK on Jul 26, 2007, 11:10 PM)


Edit Log:
Post edited by zOrK (Novice) on Jul 26, 2007, 11:10 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives