NAME
WWW::Mechanize::Plugin::DOM - HTML Document Object Model plugin for Mech
SYNOPSIS
use WWW::Mechanize;
my $m = new WWW::Mechanize;
$m->use_plugin('DOM',
script_handlers => {
default => \&script_handler,
qr/(?:^|\/)(?:x-)?javascript/ => \&script_handler,
},
event_attr_handlers => {
default => \&event_attr_handler,
qr/(?:^|\/)(?:x-)?javascript/ => \&event_attr_handler,
},
);
sub script_handler {
my($dom_tree, $code, $url, $line, $is_inline) = @_;
# ... code to run the script ...
}
sub event_attr_handler {
my($elem, $event_name, $code) = @_;
# ... code that returns a coderef ...
}
$m->plugin('DOM')->tree; # DOM tree for the current page
DESCRIPTION
blah blah blah
(event_attr|script)_handlers => {default => ... } is used when the script elem has no 'type' or 'language' attribute, and there is no Content-Script-Type header.
BUGS
The line number passed to script handlers is currently always 1, which is usually wrong if the script is inline.