Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Extracting text between HTML comments tags

by gryphon (Abbot)
on May 14, 2004 at 16:02 UTC ( #353410=note: print w/replies, xml ) Need Help??


in reply to Extracting text between HTML comments tags

Greetings Anonymous Monk,

Take a look at Template::Extract. It lets you scrape content from an HTML source without having to deal with regular experessions or parsing through tokens. (Not that I'm against HTML::TokeParser or anything. It's just that sometimes it's easier to use something else.) You copy and paste sections of HTML from which you want to extract data, put it into a tempalte file, call-out the data you want, and let the module do the work.

use Template::Extract; my $extract = Template::Extract->new(); my $template = '<!--BEGIN -->[% mydata %]<!--END -->'; my $content = '<!--BEGIN -->blah blah blooh blooh<!--END -->'; my $data = $extract->extract($template, $content); use Data::Dumper; print Dumper $data;

This is definately not going to be the fastest and probably not even the "best" way to parse your content. However, it's really, really easy. And I always say that the computer's time is cheaper than mine; make it do the work.

gryphon
code('Perl') || die;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://353410]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2020-11-24 10:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?