in reply to Re: Extracting raw text from a website
in thread Extracting raw text from a website

Hi! I mean what the user sees. Or put another way, the text that a "talking browser" would read to me if I were blind. Thanks!
  • Comment on Re^2: Extracting raw text from a website

Replies are listed 'Best First'.
Re^3: Extracting raw text from a website
by CountZero (Bishop) on Dec 03, 2009 at 20:52 UTC
    HTML::Strip will do that for you:
    use strict; use warnings; use LWP::Simple; use HTML::Strip; my $url = "http://www.perlmonks.org"; my $html = get($url); defined $html or die "Can't fetch HTML from: ",$url; my $hs = HTML::Strip->new(); my $clean_text = $hs->parse( $html ); $hs->eof; print $clean_text;
    Deleting the spurious whitespace which this module adds, is left as an exercise for the reader.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    A reply falls below the community's threshold of quality. You may see it by logging in.