Keeping up on blogs with PowerShell

Recently the top virtualization blogs were announced and updated on Eric Sieberts page here: http://vlp.vsphere-land.com This is a great place to check out for all sorts of virtualization links.

The great thing about this site is that it also gives us a chance to mess with the Invoke-WebRequest and Invoke-RestMethod cmdlets which allow us to read web information and manipulate it.

First lets grab the data from the site:

$Top50Bloggers = Invoke-WebRequest -Uri "http://vlp.vsphere-land.com"

Next we can use some regular expressions to display only the top 50 names and links:

$Top50Links = $Top50Bloggers.Links | Where {$_.innerText -match "\A(?:[0-9]\)|[0-9]{2}\))"} | Select innerHTML, href

image

Once we have the URLs we can guess at how to retrieve the RSS feed of recent posts as most blog applications list these by default under http://blogurl/rss

Given this we can easily check that page and retrieve the information using Invoke-RestMethod and pull down the posts listed, after this we can easily sort the posts, select how many of the blogs we want to see (I have chosen the last 10) and even retrieve a list of the posts which were posted today.

$Top50Bloggers = Invoke-WebRequest -Uri "http://vlp.vsphere-land.com"
$Top50Links = $Top50Bloggers.Links | Where {$_.innerText -match "\A(?:[0-9]\)|[0-9]{2}\))"} | Select innerHTML, href

$AllPosts = @()
$Top50Links | Select -First 10 | Foreach {
	$_.InnerHTML
	$link = $_.href
	$rssfeed = "$link/rss"
	try {
		$Posts = Invoke-RestMethod $rssfeed -ErrorAction SilentlyContinue | Select Title, Link, PubDate
	}
	catch {}
	$AllPosts += $Posts
}
$AllPosts | Where { $_.pubdate -match "08 Jul 2013" }

No surprises who blogged today Winking smile

image

One thought on “Keeping up on blogs with PowerShell

  1. Pingback: Обзор блогов от 15.07.13 | vMind.ru

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.