Mercurial > eagle-eye
comparison Ikariam.pm @ 10:f590b5ea5e55
fixed bug of sheep.pl
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Wed, 08 Oct 2008 09:55:43 +0800 |
parents | ae412d1f7761 |
children | 59f2c435760c |
comparison
equal
deleted
inserted
replaced
9:ae412d1f7761 | 10:f590b5ea5e55 |
---|---|
183 my $c; | 183 my $c; |
184 my $status = gunzip \$res->content => \$c | 184 my $status = gunzip \$res->content => \$c |
185 or die "gunzip failed: $GunzipError\n"; | 185 or die "gunzip failed: $GunzipError\n"; |
186 | 186 |
187 my $html = HTML::TagParser->new($c); | 187 my $html = HTML::TagParser->new($c); |
188 | |
189 # find inactivity and vacation | |
190 my %status; | |
191 foreach my $class (qw/inactivity vacation/) | |
192 { | |
193 @elems = $html->getElementsByAttribute("class", $class); | |
194 foreach my $elem (@elems) { | |
195 if($elem->innerText() =~ /^(.*?) \((\w)\)/) { | |
196 $status{$1} = $2; | |
197 # printf("%s\n", $elem->innerText()); | |
198 } | |
199 } | |
200 } | |
201 | |
202 # find content | |
188 my @elems = $html->getElementsByClassName( "cityinfo" ); | 203 my @elems = $html->getElementsByClassName( "cityinfo" ); |
189 my @cities; | 204 my @cities; |
190 foreach my $elem (@elems) { | 205 foreach my $elem (@elems) { |
191 my %info; | 206 my %info; |
192 | 207 |
201 if ( $e[0]->getAttribute("href") =~ /with=(\d+)&destinationCityId=(\d+)/) | 216 if ( $e[0]->getAttribute("href") =~ /with=(\d+)&destinationCityId=(\d+)/) |
202 { | 217 { |
203 $info{'user'} = $1; | 218 $info{'user'} = $1; |
204 $info{'cityId'} = $2; | 219 $info{'cityId'} = $2; |
205 } | 220 } |
221 | |
222 # update status; | |
223 if(defined($status{$info{'cityname'}})) { | |
224 $info{'status'} = $status{$info{'cityname'}}; | |
225 } else { | |
226 $info{'status'} = undef; | |
227 } | |
228 # print(Dumper(\%info)); | |
206 push @cities, \%info; | 229 push @cities, \%info; |
207 } | 230 } |
208 | 231 |
209 return @cities; | 232 return @cities; |
210 } | 233 } |