Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Wise ones:

WWW::Robot seems to work well for following URLs of various types as long as they are type http. But I am getting confused as to where I would set up the ability to follow a link that uses JavaScript to open.window example html/JS further below).

My instance of WWW::Robot is similar to most that I see out there. Can anyone point me to a good source of info on this? Many thanks.

... my $robot = WWW::Robot->new ( NAME => 'UsageBot', VERSION => '1.0', EMAIL => 'me@myaddress.com', USERAGENT => LWP::UserAgent->new, CHECK_MIME_TYPES => 0, IGNORE_TEXT => 0 ); $robot->addHook ("follow-url-test" => sub { my ($robot, $hook, $url) = @_; return 0 unless $url->scheme eq 'http'; OK_TO_FOLLOW($url); });

Doesn't seem to follow existing HTML like this:

<a href="#" onClick="popWindow('usage')"...>...</a> function popWindow(wintype){ if (wintype == "usage"){window.open 'usage_stats.html', 'server_stat...)...}

Replies are listed 'Best First'.
Re: WWW:Robot to follow links through JavaScript
by hardburn (Abbot) on Aug 01, 2003 at 15:26 UTC

    To fix that, WWW::Robot would need to execute JavaScript. Good luck on that.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated