Domanda

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.

È stato utile?

Soluzione

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...

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top