Mercurial > eagle-eye
changeset 367:d9d3cdff27c6
handling field not found error
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Sun, 01 Mar 2009 22:14:05 +0800 |
parents | 2cfa03edc22e |
children | 95148fdc1021 |
files | Ikariam.pm |
diffstat | 1 files changed, 25 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/Ikariam.pm Sun Mar 01 11:10:52 2009 +0800 +++ b/Ikariam.pm Sun Mar 01 22:14:05 2009 +0800 @@ -638,9 +638,18 @@ my $city = Ikariam::Cities->retrieve($cityId); $city->delete; } else { - $self->{mech}->submit_form( - form_number => 1, - fields => $fields); + $self->{mech}->form_number(1); + + foreach my $k (keys(%{$fields})) { + eval{ + $self->{mech}->field($k, $fields->{$k}) + }; + warn $@ if($@); + } + $self->{mech}->submit(); +# $self->{mech}->submit_form( +# form_number => 1, +# fields => $fields); } } else { # put the id in the friends.txt file. @@ -1262,17 +1271,21 @@ password => $self->{pass}, ]); - my @cities = Ikariam::Extractor->new(content => $res->content)->find('//option[@class="avatarCities coords"]/@value'); + while (1) { + my @cities = Ikariam::Extractor->new(content => $res->content)->find('//option[@class="avatarCities coords"]/@value'); - if($#cities<0) { - die ("login failed\n"); - } - foreach (@cities) { - $self->{'cities'}->{$_} = {}; - $self->{'cities'}->{$_}->{id} = $_; - if(-f "city-$_-dump.yaml") { - $self->{'cities'}->{$_} = LoadFile("city-$_-dump.yaml"); + if($#cities<0) { + warn ("login failed\n"); + next; } + foreach (@cities) { + $self->{'cities'}->{$_} = {}; + $self->{'cities'}->{$_}->{id} = $_; + if(-f "city-$_-dump.yaml") { + $self->{'cities'}->{$_} = LoadFile("city-$_-dump.yaml"); + } + } + last; } }