Showing posts with label games. Show all posts
Showing posts with label games. Show all posts

Thursday, February 15, 2007

Scripting Games 2007 - Live Scores

This little script will parse the scores table on the scripting games website and output the results into the console. It is working kinda slow due to some PS inconsistencies regarding IE automation, so I'll have to keep on checking on it . Meanwhile, get your own results ;-)

 

[string]$url="http://www.microsoft.com/technet/scriptcenter/funzone/games/games07/psascores.mspx"
$ie=new-object -com internetexplorer.application
$ie.visible=$true
$ie.navigate($url)
while($ie.ReadyState -ne 4) {start-sleep -m 500}

$ds = new-object "System.Data.DataSet" $ds.Tables.Add("score")
[void]$ds.Tables[0].Columns.Add("Name",[string])
[void]$ds.Tables[0].Columns.Add("Country",[string])

1..10 | foreach {
    [void]$ds.Tables[0].Columns.Add("e$_",[string])}
    [void]$ds.Tables[0].Columns.Add("Total",[string])
    $table = $ie.document.getElementById("E4")
    $trs=$table.GetElementsByTagName("TR")
    $trs | foreach {     
        $tds = $_.GetElementsByTagName("TD")     
        $x=0     
        $dr = $ds.Tables[0].NewRow()     
        $tds | foreach {$dr[$x] = $_.innerText}     
        $x++
    }
}   

$ds.Tables[0].Rows.Add($dr)
$ds.Tables[0].rows[0].delete()
$ds.tables | ft * -auto

$hay