论坛首页 编程语言技术论坛

PowerShell 脚本读取 rss 新闻

浏览 2129 次
精华帖 (0) :: 良好帖 (5) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-02-10   最后修改:2010-02-10

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

 

论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics