use Encode;
use HTML::TreeBuilder;
use HTML::Element;
use Data::Dumper qw(Dumper);
$Data::Dumper::Indent = 1;
undef $/;
$oldscore=$score=0;
$times = 0;
for ( $times=0;$times <= 50; $times++){
system("wget","http://score.espnstar.com.cn/","-Oindex.html");
open($fd,"<index.html");
$string = <$fd>;
$string = decode("gb2312", $string);
$string = encode("utf8", $string);
$tree = HTML::TreeBuilder->new_from_content($string);
foreach $row ( $tree->find_by_tag_name("tr") ) {
$line = "";
foreach $cell ( $row->content_list ) {
$line = $line.$cell->as_text." ";
}
if ($line =~ /°ÝÈÊĽÄáºÚ/gs) {
if ( $line =~ /(\d*) - (\d*)/gs) {
$score= $1.$2;
}
if($score ne $oldscore){
$cmd='curl -x 222.171.7.131:7628 -u user@mail.com:passwd -d status="'.$line.'"'." " .'http://twitter.com/statuses/update.xml';
system($cmd);
$oldscore=$score;
}
}
}
$tree->delete();
close($fd);
system("rm","index.html");
sleep 300;
}