Malincy Montoya
Malincy Montoya

Reputation: 87

find_all_links() Perl function doesn't find all links

I'm starting with Perl and I'm trying to do a script that logs me out of a page (I already did the login one). The idea is, I'm trying to use find_link function from WWW::Mechanize (I also tried WWW::Mechanize::Firefox) to find the logout link, but it's not working. So, my question is:

is the event onmouseover avoiding that link to be found? I think WWW::Mechanize::Firefox supports javascript but maybe that's not correct.

<a class="hb2" href="/goform/Logout?logout=Logout" onmouseover="(window.status='Logout');
return true">Logout</a>

Is there a way to do what I want? Any help or suggestions will be highly appreciated.

Upvotes: 0

Views: 451

Answers (3)

Malincy Montoya
Malincy Montoya

Reputation: 87

Apparently my MozRepl (needed to use WWW::Mechanize::Firefox) add-on was not well installed. @gangabass, @andy I checked the HTML and it seemed to be in the source. So @choroba I checked why WWW::Mechanize::Firefox was acting the same as WWW::Mechanize and I reinstalled the add-on. Then everything worked perfect. Thanks a lot to all of you for taking time to help me.

Upvotes: 1

Andy Lester
Andy Lester

Reputation: 93676

Have you dumped the page with the mech-dump command line utility? Try that. If your link shows up in the output of mech-dump then you're calling find_all_links() wrong.

If mech-dump does not show your link, then you probably either have malformed HTML, or the HTML is generated in the browser with JavaScript.

Upvotes: 0

gangabass
gangabass

Reputation: 10666

Are you sure you have this HTML fragment in your source HTML? I mean your HTML code fragment may be created dynamically via Javascript or may be you have frames in your source HTML.

So please show output of $mech->content() and your code to process this link (as stated above $mech->find_link( text => 'Logout' ); should work).

Upvotes: 0

Related Questions