Re: 2nd try: reusing parsing of LinkExtor for FormatText
Aaron Nabil (nabil@teleport.com)
Tue, 8 Oct 1996 03:41:12 -0700 (PDT)
nabil writes...
> # get the document something like this
>
> $ua = new LWP::UserAgent;
> $req = new HTTP::Request 'GET' => $url;
> $res = $ua->request($req);
>
> ( . . . )
>
> my $le_parser = HTML::LinkExtor->new(\&extor_cb, $base);
> $le_parser->netscape_buggy_comment(1);
> $le_html = $le_parser->parse($res->content);
>
> # This part above works find and correctly calls extor_cb to process
> # this links.
>
> my $formatter = new HTML::FormatText;
>
> # here's what I like to do, reusing the parser run.
> # print $formatter->format($le_html);
> # But it dies with...
> # Can't locate object method "traverse" via package "HTML::LinkExtor" at
> # /usr/local/perl/lib/site_perl/HTML/Formatter.pm line 65, <> chunk 1.
Though I'd try this and see what happens...
{
package ElementLinkExtor;
@ISA = qw(HTML::LinkExtor HTML::Element);
1;
}
I have no idea what the 1 means, BTW.
my $le_parser = HTML::ElementLinkExtor->new(\&extor_cb, $base);
( . . . )
No error message about "traverse", and it still found the links, but the
formatter didn't output anything but a newline.