What subroutine is missing? I am basically trying to save as a string the non-HTML content of a website using that part od the WWW::Mechanize code. | [reply] |
You had: $stripped_html[$x] = $webcrawler( format => "text");
$webcrawler is a scalar. If it were a scalar code ref, you could do &$webcrawler( format => 'text' ), but it looks to be to be a WWW::Mechanize object. So, what you have is a scalar, then two more scalars in parenthesis.
You need some sort of operator between the '$webcrawler' and the parenthesis. More than likely, based on the parentheis, you're missing a method call:
$webcrawler->method( format => 'text' );
So, what method call takes a hash as its argument, and one of the keys is format? We look at the documentation for WWW::Mechanize, and search for the string 'format', and we find the following: $mech->content( format => "text" )
So, I can only guess that you should have written:
$stripped_html[$x] = $webcrawler->content( format => "text");
| [reply] [d/l] [select] |
use warnings;
use strict;
use WWW::Mechanize;
use HTML::TreeBuilder;
my $webcrawler = WWW::Mechanize->new();
my $page = $webcrawler->get ('http://perlmonks.org/?node_id=479598');
my $tree = HTML::TreeBuilder->new_from_content ($page->as_string ());
print $tree->as_text ();
Perl is Huffman encoded by design.
| [reply] [d/l] [select] |