Mercurial > eagle-eye
comparison Ikariam.pm @ 207:48ea8222782a
automatic build spys
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Mon, 03 Nov 2008 18:40:15 +0800 |
parents | d9f17bcbf1f1 |
children | a5862d3f1c84 |
comparison
equal
deleted
inserted
replaced
206:b7af307a222d | 207:48ea8222782a |
---|---|
505 form_number => 1, | 505 form_number => 1, |
506 fields => { | 506 fields => { |
507 $unitType => 1, | 507 $unitType => 1, |
508 } | 508 } |
509 ); | 509 ); |
510 } | |
511 } | |
512 | |
513 sub buildSpy { | |
514 my $self = shift; | |
515 my $unitType = shift; | |
516 my $cityId = shift; | |
517 my $type = 'safehouse'; | |
518 | |
519 my $position = -1; | |
520 my @locations = @{$self->{'cities'}->{$cityId}->{locations}}; | |
521 foreach (2..$#locations) { | |
522 $position = $_ if($locations[$_] eq $type); | |
523 } | |
524 | |
525 if($position != -1) { | |
526 my $res = $self->{mech}->get (sprintf("http://%s/index.php?view=%s&id=%s&position=%d", $self->{server}, $type, $cityId, $position)); | |
527 my $url = | |
528 Ikariam::Extractor->new(content => $res->content)->find(sprintf('//div[@class="forminput"]/a/@href')); | |
529 $self->{mech}->get($url) if(defined($url)); | |
510 } | 530 } |
511 } | 531 } |
512 | 532 |
513 sub build { | 533 sub build { |
514 my $self = shift; | 534 my $self = shift; |