mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-23 02:18:21 +02: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.
|
This PowerShell script lists the latest RSS feed news.
|
||||||
.PARAMETER RSS_URL
|
.PARAMETER RSS_URL
|
||||||
Specifies the URL to the RSS feed
|
Specifies the URL to the RSS feed
|
||||||
.PARAMETER MaxCount
|
.PARAMETER maxCount
|
||||||
Specifies the number of news to list
|
Specifies the number of news to list
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-headlines.ps1
|
PS> ./list-headlines.ps1
|
||||||
@ -17,19 +17,19 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
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 {
|
try {
|
||||||
[xml]$Content = (Invoke-WebRequest -uri $RSS_URL -useBasicParsing).Content
|
[xml]$content = (Invoke-WebRequest -uri $RSS_URL -useBasicParsing).Content
|
||||||
[int]$Count = 0
|
[int]$count = 0
|
||||||
foreach ($item in $Content.rss.channel.item) {
|
foreach ($item in $content.rss.channel.item) {
|
||||||
"❇️ $($item.title)"
|
"❇️ $($item.title)"
|
||||||
$Count++
|
$count++
|
||||||
if ($Count -eq $MaxCount) { break }
|
if ($count -eq $maxCount) { break }
|
||||||
}
|
}
|
||||||
$Source = $Content.rss.channel.title
|
$source = $Content.rss.channel.title
|
||||||
$Date = $Content.rss.channel.pubDate
|
$date = $Content.rss.channel.pubDate
|
||||||
"(by $Source as of $Date)"
|
" (by $source as of $date)"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user