ITeye博客

PowerShell 脚本读取 rss 新闻

vv_1024 · 2010-02-10 13:22 · Windows · 操作系统 · Windows · .net · XML · 脚本 · PowerShell · Markdown

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 + "     ")
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。