PowerShell 脚本读取 rss 新闻

Windows 7 中的PowerShell 脚本很强大,可以直接使用COM组件和.Net类。下面是语音播报热点新闻。

$sapi = New-Object -Com Sapi.SpVoice
$WebClient = New-Object System.Net.WebClient
#$WebClient.Encoding=[System.Text.Encoding]::GBK
$rss = [XML]($WebClient.DownloadString("http://news.163.com/special/00011K6L/rss_newstop.xml"))
foreach($item in $rss.rss.channel.Item){
    $title = $item.title.InnerText
    $content = $item.description.InnerText.Replace("&nbsp","")
    $title
    $sapi.Speak($title)
    $content
    $sapi.Speak($content + "     ")
}

相关推荐