Friday, May 21, 2010

How to read the text of a web page using perl?

how to read the text of a web page using perl





Eg: How can i read the only text contents of www.yahoo.com

How to read the text of a web page using perl?
Use LWP





http://search.cpan.org/~gaas/libwww-perl... has examples (including http://search.cpan.org/~gaas/libwww-perl...
Reply:# UNTESTED CODE:


use strict; use warnings;


use HTML::FormatText;


use HTML::TreeBuilder;


use LWP::Simple;


my $s = get('www.yahoo.com');


my $tree = HTML::TreeBuilder::new;


$tree-%26gt;parse_content($s);


my $formatter = new HTML::FormatText;


print $formatter-%26gt;format($tree);

flower arrangement

No comments:

Post a Comment