mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-16 09:50:02 +01:00
Update list-headlines.ps1
This commit is contained in:
parent
46c67aab1f
commit
f78fc2ed9f
@ -5,7 +5,7 @@
|
||||
This PowerShell script lists the latest RSS feed news.
|
||||
.PARAMETER RSS_URL
|
||||
Specifies the URL to the RSS feed
|
||||
.PARAMETER MaxCount
|
||||
.PARAMETER maxCount
|
||||
Specifies the number of news to list
|
||||
.EXAMPLE
|
||||
PS> ./list-headlines.ps1
|
||||
@ -17,19 +17,19 @@
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$RSS_URL = "https://yahoo.com/news/rss/world", [int]$MaxCount = 20)
|
||||
param([string]$RSS_URL = "https://yahoo.com/news/rss/world", [int]$maxCount = 20)
|
||||
|
||||
try {
|
||||
[xml]$Content = (Invoke-WebRequest -uri $RSS_URL -useBasicParsing).Content
|
||||
[int]$Count = 0
|
||||
foreach ($item in $Content.rss.channel.item) {
|
||||
[xml]$content = (Invoke-WebRequest -uri $RSS_URL -useBasicParsing).Content
|
||||
[int]$count = 0
|
||||
foreach ($item in $content.rss.channel.item) {
|
||||
"❇️ $($item.title)"
|
||||
$Count++
|
||||
if ($Count -eq $MaxCount) { break }
|
||||
$count++
|
||||
if ($count -eq $maxCount) { break }
|
||||
}
|
||||
$Source = $Content.rss.channel.title
|
||||
$Date = $Content.rss.channel.pubDate
|
||||
"(by $Source as of $Date)"
|
||||
$source = $Content.rss.channel.title
|
||||
$date = $Content.rss.channel.pubDate
|
||||
" (by $source as of $date)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Loading…
Reference in New Issue
Block a user