#!/usr/bin/perl -w
use Encode;
use HTML::TreeBuilder;
use HTML::Element;
use Data::Dumper qw(Dumper);
$Data::Dumper::Indent = 1;
undef $/;
$oldscore=$score=0;
$times = 0;
#300*50 = 15000 secs for overtime match
for ( $times=0;$times <= 50; $times++){
    system("wget","http://score.espnstar.com.cn/","-Oindex.html");
    open($fd,"<index.html");
    $string = <$fd>;
#index.html's code is gb2312 and i use utf8
    $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." ";
        }
#search for line which is about your team.Here i use °ÝÈÊĽÄáºÚ
        if ($line =~ /°ÝÈÊĽÄáºÚ/gs) {
            if ( $line =~ /(\d*) - (\d*)/gs) {
                $score= $1.$2;
            }
#score has updates.so twitter It...
            if($score ne $oldscore){
                #you have to have curl
                $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;
}