1

我需要能够关注网页上的点击。这是我到目前为止的代码。

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....
4

1 回答 1

1
# 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";

文档对提出这一点非常有帮助。

于 2013-10-08T01:58:35.943 回答