Subject: | $mech->find_all_inputs (and $mech->find_all_submits) doesn't :( |
Attached is an example of this failure. I was orginally using v1.20,
using $mech->inputs to try and find why a 'next' button couldn't be
found. Have now upgraded to 1.30 and added the $mech->find_all_inputs
(find_all_submits has the same fault), and it's failing to find all the
imputs/submits for this particular form.
If you look at the view source for the page I'm looking at
(http://vienna.yapceurope.org/ye2007/search), you'll see that there is
only one form, and that it terminates at the end of the page with a
further hidden field and a second submit button. On subsequent pages
there is another hidden field and a third submit button. Unfortunately
all the above functions failed to find any of the extra inputs/submits,
such that trying to submit the form with the named button fails.
I'm guessing that because there is other HTML code between the two, a
closing tag within that form also closes the form automatically, even
though it is still nested hasn't been closed.
Subject: | crawler.pl |
#!/usr/bin/perl -w
use strict;
#############################################################################
#Library Modules #
#############################################################################
use WWW::Mechanize;
#############################################################################
#Global Variables #
#############################################################################
my $BASE = 'http://vienna.yapceurope.org/ye2007/search';
my $mech = WWW::Mechanize->new();
$mech->agent_alias( 'Linux Mozilla' );
#############################################################################
#Code Block #
#############################################################################
$mech->get( $BASE );
while($mech->success()) {
my @forms = $mech->forms;
for my $form (@forms) {
print STDERR "FORM: ".$form->attr( 'name' ).'/'.$form->attr( 'id' )."\n";
my @inputs = $form->inputs;
for my $input (@inputs) {
print STDERR " INPUT: ".$input->type().'/'.$input->name()."\n";
}
}
my @submits = $mech->find_all_submits();
for my $submit (@submits) {
print STDERR " INPUT: ".$submit->type().'/'.$submit->name()."\n";
}
$mech->click_button( name => 'next' );
}