7.16.2010

PowerShell Simple RSS Reader

I subscribe to numerous RSS feeds. Some of the feeds contain useful information; but others require some filtering to be useful.

For example, I subscribe to a feed from my favorite local computer book store SoftPro Books. I have setup a a small snippet of PowerShell to access their New Arrival’s RSS feed and look for any new titles matching a specific text in this case, “asp”.

This script is fairly simple; but I could easily modify it to search a text file of keywords (perhaps author names or specific titles), or even go one step further to scrape the html from the item link to search the information about the book.

Another option would be to have this script run on a schedule or via my PowerShell profile. I could even create and publish a filtered rss feed that would just show the title’s I’m interested in.

 
#Create a WebClient to fetch the feed
$wc = new-object System.net.WebClient
$feedUrl = "http://www.softprorss.com/web-arrivals.rss"

#Download the feed as Xml
$rssContent = [xml]$wc.DownloadString($feedUrl)

# read the xml
$rssContent.rss.channel.Item | ? {$_.title -match "asp"} | ft title, link -auto

No comments: