A
Andreas Grothey
Hello,
I'm fairly new to Perl, so excuse me if I've missed something obvious.
It seems to me that HTML:Form doesn't work correctly if a Form has
several "select" fields of the same name.
This is what I am trying to do:
I'm taking part in Yahoo's Football Manager game (so this is all for
fun, but the excuse is that I'm trying to learn Perl this way). This
game requires a lot of tedious clicking through forms and pages, so I
thought I'd automate a lot of it using WWW::Mechanize. One of the
pages (to choose where to play which player) has a lot of "select"
fields on it, quite a few of them with repeated name (i.e. 3 named
'sturm' (=forward) if you play with 3 forwards and so on). The page is
http://de.footballmanager.yahoo.net/yfbm/positionen.view, you have to
be registered in the game to view it though.
From looking through WWW::Mechanize I thought that something like
$mech->submit_form(
form_number => 1,
fields => {
sturm => [8, 2],
}
);
would set the second 'sturm' field to 8 (i.e player number 8).
However Perl complains that it cannot find a second field of that
name.
I've spend quite a lot of time looking through WWW::Mechanize and
HTML::Form (which is called from it), and I think the problem is that
HTML::Form simply doesn't treat 'select' fields correctly: if it finds
an 'option' tag in a 'select' field it goes and looks whether it
already knows a 'select' of this name and appends the option. The
possibility that this might be a second select of the same name
doesn't seem to be tested for. The information from a closing /select
is ignored. I've actually hacked in HTML::Form adding a counter to
distiguish between different "select"s and it seems to be working for
me now.
Although as I'm fairly new to Perl, I've probably broken something
somewhere else.
So have I missed something obvious in how to use HTML::Form or
WWW::Mechanize, or have I found a bug?
Any thought?
Andreas
PS: I'm using Perl 5.8.6, HTML::Form v1.49 and WWW::Mechanize v1.06
which are the newest I could find
I'm fairly new to Perl, so excuse me if I've missed something obvious.
It seems to me that HTML:Form doesn't work correctly if a Form has
several "select" fields of the same name.
This is what I am trying to do:
I'm taking part in Yahoo's Football Manager game (so this is all for
fun, but the excuse is that I'm trying to learn Perl this way). This
game requires a lot of tedious clicking through forms and pages, so I
thought I'd automate a lot of it using WWW::Mechanize. One of the
pages (to choose where to play which player) has a lot of "select"
fields on it, quite a few of them with repeated name (i.e. 3 named
'sturm' (=forward) if you play with 3 forwards and so on). The page is
http://de.footballmanager.yahoo.net/yfbm/positionen.view, you have to
be registered in the game to view it though.
From looking through WWW::Mechanize I thought that something like
$mech->submit_form(
form_number => 1,
fields => {
sturm => [8, 2],
}
);
would set the second 'sturm' field to 8 (i.e player number 8).
However Perl complains that it cannot find a second field of that
name.
I've spend quite a lot of time looking through WWW::Mechanize and
HTML::Form (which is called from it), and I think the problem is that
HTML::Form simply doesn't treat 'select' fields correctly: if it finds
an 'option' tag in a 'select' field it goes and looks whether it
already knows a 'select' of this name and appends the option. The
possibility that this might be a second select of the same name
doesn't seem to be tested for. The information from a closing /select
is ignored. I've actually hacked in HTML::Form adding a counter to
distiguish between different "select"s and it seems to be working for
me now.
Although as I'm fairly new to Perl, I've probably broken something
somewhere else.
So have I missed something obvious in how to use HTML::Form or
WWW::Mechanize, or have I found a bug?
Any thought?
Andreas
PS: I'm using Perl 5.8.6, HTML::Form v1.49 and WWW::Mechanize v1.06
which are the newest I could find