문제

I'm trying to find tags in a html with a perl script.

 use WWW::Mechanize::Firefox;
 use Crypt::SSLeay;
 use HTML::TokeParser;
 $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;

 my $mech = WWW::Mechanize::Firefox->new;
 $mech->get_local('salida2.html');
 my @links = $mech->links();
 print @links;


 my $parser = HTML::TokeParser->new('salida2.html') || die $!;
 my $tag = $parser->get_tag('ul');

I get this error Can't call method "get_tag" on an undefined value at C:\Users\me\Documents\Scripts\parsing.pl line 9.

salida2.html is under the same directory than the script and I'm also using it with an WWW::Mechanize::Firefox instance and it's working fine.

Thank you in advance.

도움이 되었습니까?

해결책

The clue is in the error you get. The file may be in the same directory as your script, but that doesn't mean that that's your working directory! Either chdir to the right directory or use a fully qualified path...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top