From: Patrik Hasibuan <[EMAIL PROTECTED]> > I want to parse HTML files those I retrieve with "LWP::UserAgent". For the > parsing I use "HTML::Parser". > But the parsing process does not give any result. I still do not understand > the documentation those I get from > - http://www.foo.be/docs/tpj/issues/vol5_1/tpj0501-0003.html ; > - http://search.cpan.org/~gaas/HTML-Parser-3.56/Parser.pm . > > Please tell me where my mistake for making me understand how to use this HTML > Parser Module. > === > Here is my current code: > #!/usr/bin/perl -w > use strict; > use LWP::UserAgent; > use HTML::Parser; > > my @result=''; > my $tekshslparse=''; > > my $ua = LWP::UserAgent->new; > $ua->agent("Mozilla/8.0"); > > my $req = HTTP::Request->new(GET => 'http://www.google.com'); > $req->header('Accept' => 'text/html'); > > my $retriveresult = $ua->request($req);
Did you try to print the $retriveresult? What did you see? The HTML? I guess not! > my $p=new HTML::Parser; > $tekshslparse=$p->parse($retriveresult); > > print @result; I do not see anything updateing the @result array. > sub text{ > my($self, $text)[EMAIL PROTECTED]; > print "self: $self \n\n"; > print "text: $text \n\n"; > } Why do you think this subroutine will ever be called? You should reread the HTML::Parser's docs and try to parse a simple, short static HTML before you try to download the Google homepage and parse that. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/