# HG changeset patch # User "Rex Tsai " # Date 1225474479 -28800 # Node ID b23077d597b073be5c5c04cc170a9cd3b44b06cf # Parent 7f9109a50679a1036e84e2df210e71a9f225fea0# Parent aad08889ddb3be5579b34c702aa0cdb3aa1b88ce fixed. diff -r aad08889ddb3 -r b23077d597b0 Ikariam.pm --- a/Ikariam.pm Fri Oct 31 18:01:21 2008 +0800 +++ b/Ikariam.pm Sat Nov 01 01:34:39 2008 +0800 @@ -95,7 +95,6 @@ use LWP; use HTTP::Cookies; use WWW::Mechanize; -use HTML::TagParser; use XML::LibXML qw(:encoding); use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ; use POSIX; @@ -578,14 +577,10 @@ $report{defender} = $extractor->find('//div[@id="troopsReport"]//table[@id="result"]//th[@class="defenders"]'); $report{winner} = $extractor->find('//div[@id="troopsReport"]//table[@id="result"]//td[@class="winner"]'); - my $href; - if($self->{server} ne "s4.ikariam.tw") { - $report{targetCity} = $extractor->find('//div[@id="troopsReport"]/div/h3/a/text()'); - $href = $extractor->find('//div[@id="troopsReport"]/div/h3/a/@href'); - } else { - $report{targetCity} = $extractor->find('//td[@class="battle"]/a/text()'); - $href = $extractor->find('//td[@class="battle"]/a/@href'); - } + $report{targetCity} = $extractor->find('//div[@id="troopsReport"]/div/h3/a/text()'); + my $href = $extractor->find('//div[@id="troopsReport"]/div/h3/a/@href'); + # $report{targetCity} = $extractor->find('//td[@class="battle"]/a/text()'); + # my $href = $extractor->find('//td[@class="battle"]/a/@href'); if($href =~ /index\.php\?view=island&id=(\d+)&selectCity=(\d+)/) { $report{island} = $1; @@ -918,43 +913,5 @@ } } -sub getElementsByTagName { - my $element = shift; - my $tagname = lc(shift); - my ( $flat, $cur ) = @$element; - - my $out = []; - for( ; $cur <= $#$flat ; $cur++ ) { - last if ($flat->[ $cur + 1 ]->[001] eq $element->tagName() ); - next if ($flat->[$cur]->[001] ne $tagname ); - next if $flat->[$cur]->[000]; # close - - my $elem = HTML::TagParser::Element->new( $flat, $cur ); - return $elem unless wantarray; - push( @$out, $elem ); - } - return unless wantarray; - @$out; -} - -sub getElementsByAttribute { - my $element = shift; - my $key = lc(shift); - my $val = shift; - my ( $flat, $cur ) = @$element; - - my $out = []; - for ( ; $cur <= $#$flat ; $cur++ ) { - next if $flat->[$cur]->[000]; # close - my $elem = HTML::TagParser::Element->new( $flat, $cur ); - my $attr = $elem->attributes(); - next unless exists $attr->{$key}; - next if ( $attr->{$key} ne $val ); - return $elem unless wantarray; - push( @$out, $elem ); - } - return unless wantarray; - @$out; -} 1;