PoshCode Archive  Artifact [b3d7c5ab22]

Artifact b3d7c5ab225d9103da7bbcfd38fe238b8e8f477ec2b4ebc833f74ec677249542:

  • File Get-FeedInfo.ps1 — part of check-in [549f7dff33] at 2018-06-10 13:00:13 on branch trunk — Takes an array of RSS feed URLs and gets the site URL and title.. (user: unknown size: 1220)

# encoding: ascii
# api: powershell
# title: Get-FeedInfo
# description: Takes an array of RSS feed URLs and gets the site URL and title..
# version: 0.1
# type: function
# license: CC0
# function: Get-FeedInfo
# x-poshcode-id: 1698
# x-archived: 2010-03-23T07:13:12
#
#
function Get-FeedInfo([string[]]$feeds) {
# $feeds is an array of rss/atom URLs 
$blogs=@(); $broken=@(); $feeds = $feeds | sort -unique {$_}
foreach($feed in $feeds){ 
   try { 
      $xml = Get-WebPageContent $feed;
   } catch { 
      $broken += $feed
      $xml = $null
   }
   if($xml.html.rss) { $xml = $xml.html; write-warning $feed }
   if($xml.rss) {
      $blogs += New-Object PSObject -Property @{ 
         title= $xml.rss.channel.title
         link = $xml.rss.channel.link | ? { $_ -is [string] }
         feed = $feed 
      }
   } elseif($xml.feed) {
      $blogs += New-Object PSObject -Property @{ 
         title= $xml.feed.title.'#text'
         link = $xml.feed.link |? {$_.rel -eq 'alternate' } | select -expand href
         feed = $feed 
      }
   } else {
      $broken += $feed
      $blogs += New-Object PSObject -Property @{ feed = $feed }
   }
}
Write-Output $blogs, $broken
}