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

I am using WWW::Mechanize to navigate around a site. I have a problem where RubyRails generated web pages are creating a href that does a delete.

 <a href="/accounts/112159/account_views/983516" data-confirm="Remove user bob test from account?" data-method="delete" rel="nofollow"><img alt="Icon-trash" src="/images/v4/icon-trash.png?cb4c0a4" /> Delete</a>

so i would like to do

$result = $m->follow_link( url_regex => qr/account_views\/983516/i );

but the href runs some sort of script and opens a popup box to confirm if you really want to delete.

Anyone know how to cope with this in perl LWP ?

Many thanks

Replies are listed 'Best First'.
Re: href with data-method="delete"
by marto (Cardinal) on Jan 31, 2014 at 13:50 UTC

    "but the href runs some sort of script and opens a popup box to confirm if you really want to delete."

    Sounds like JavaScript. WWW::Mechanize:

    "Please note that Mech does NOT support JavaScript, you need additional software for that. Please check "JavaScript" in WWW::Mechanize::FAQ for more."

Re: href with data-method="delete"
by PerlSufi (Friar) on Jan 31, 2014 at 17:42 UTC
    hello,
    I would suggest using something like the firefox HTTP live headers plugin while browsing the site, see what posts and gets are performed, and replicating that with your script. But, as marto referenced, WWW::Mechanize will not work with javascript. The only way I've gotten around it is by performing the actual GET that is performed instead of following a link.