PoshCode Logo PowerShell Code Repository

A simple cached RSS reader. Fetches RSS feeds, displays mutliple feeds merged in date order, opens items in browser.

  1. ## Simplest RSS Reader
  2. ####################################################################################################
  3. ## Save this file as Start-RssReader.ps1
  4. ## Run it like:
  5. ##     .\Start-RssReader "http://feeds.feedburner.com/powerscripting", "http://HuddledMasses.org/feed"
  6. ## And then:
  7. ##    Get-RSS          # to (re)fetch the feeds and view
  8. ##    Show-RSS         # to view without re-fetching
  9. ##    Open-RSSItem 2   # to open an item in your browser
  10. ####################################################################################################
  11. PARAM(
  12.    [string[]]$RssReaderUrls = $(do{
  13.                            $k = Read-Host "Specify an RSS Feed URL (hit Enter when done)"
  14.                            if($k) {write-output $k}
  15.                         } while($k) )
  16. )
  17.  
  18. function global:Get-RSS {
  19.    $webClient = New-Object System.Net.WebClient
  20.    $global:RssReaderNews = $RssReaderUrls | % { [xml]$webClient.DownloadString( $_ ) } |
  21.                             % { $_.rss.channel.item } |
  22.                             Sort { [DateTime]$_.pubDate } -Desc
  23.    Show-RSS
  24. }
  25.  
  26. function global:Show-RSS($days=7) {
  27.    $script:index = -1
  28.    $global:RssReaderNews | Where { ([DateTime]$_.pubDate).AddDays($days) -gt [DateTime]::Now } |
  29.            ft @{l="Index";e={return $script:index++}},@{l="Day";e={$_.pubDate.split(",",2)[0]}}, title, link -auto
  30. }
  31.  
  32. function global:Open-RssItem($index=0) {
  33.    [Diagnostics.Process]::Start( $($global:RssReaderNews[$index].link) )
  34. }
  35. $global:RssReaderUrls = $RssReaderUrls
  36. Get-RSS

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me