简体   繁体   English

使用WWW :: Mechanize :: Firefox使用onclick

[英]using WWW::Mechanize::Firefox to use an onclick

I need to be able to follow an onclick on a webpage. 我需要能够跟踪网页上的onclick。 Here's the code I have so far. 这是我到目前为止的代码。

use strict;
use warnings;
use WWW::Mechanize::Firefox;

# Create a new instance of Mechanize
my $mech = WWW::Mechanize::Firefox->new();

# Go to page
$mech->get('http://www.website.com');

# TODO
# use a buttons onclick somehow....
# Go to page
$mech->get('http://www.google.com');

# Fill in the query box
$mech->field( q => "turtles" );

# Click the Feeling Lucky Button
$mech->click( { xpath => '//button[@name="btnI"]' } );

# Get the title of the result page
my $page_title = $mech->title();

print "$page_title\n";

The documentation was pretty helpful in coming up with this. 文档对于解决此问题非常有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM