mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-22 07:53:21 +01:00
Updated list-news.ps1 and list-headlines.ps1
This commit is contained in:
parent
eca81b91d5
commit
5ad06bb3d3
@ -2,11 +2,11 @@
|
||||
.SYNOPSIS
|
||||
Lists the latest headlines
|
||||
.DESCRIPTION
|
||||
This PowerShell script lists the latest RSS feed news.
|
||||
This PowerShell script lists the latest headlines by using a RSS (Really Simple Syndication) feed.
|
||||
.PARAMETER RSS_URL
|
||||
Specifies the URL to the RSS feed
|
||||
.PARAMETER maxCount
|
||||
Specifies the number of news to list
|
||||
Specifies the URL to the RSS feed (Yahoo World News by default)
|
||||
.PARAMETER maxLines
|
||||
Specifies the maximum number of lines to list (24 by default)
|
||||
.EXAMPLE
|
||||
PS> ./list-headlines.ps1
|
||||
❇️ Niger coup: Ecowas deadline sparks anxiety in northern Nigeria
|
||||
@ -17,18 +17,17 @@
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$RSS_URL = "https://www.yahoo.com/news/rss", [int]$maxCount = 20)
|
||||
param([string]$RSS_URL = "https://news.yahoo.com/rss/world", [int]$maxLines = 24)
|
||||
|
||||
try {
|
||||
[xml]$content = (Invoke-WebRequest -uri $RSS_URL -useBasicParsing).Content
|
||||
[int]$count = 0
|
||||
[xml]$content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content
|
||||
[int]$count = 1
|
||||
foreach ($item in $content.rss.channel.item) {
|
||||
"❇️ $($item.title)"
|
||||
$count++
|
||||
if ($count -eq $maxCount) { break }
|
||||
if ($count++ -eq $maxLines) { break }
|
||||
}
|
||||
$source = $Content.rss.channel.title
|
||||
$date = $Content.rss.channel.pubDate
|
||||
$source = $content.rss.channel.title
|
||||
$date = $content.rss.channel.pubDate
|
||||
" (by $source as of $date)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
@ -1,10 +1,10 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
List the latest news
|
||||
Lists the latest news
|
||||
.DESCRIPTION
|
||||
This PowerShell script lists the latest news by using RSS (Really Simple Syndication) feeds.
|
||||
This PowerShell script lists the latest news by using a RSS (Really Simple Syndication) feed.
|
||||
.PARAMETER RSS_URL
|
||||
Specifies the URL to the RSS feed (Yahoo News by default)
|
||||
Specifies the URL to the RSS feed (Yahoo World News by default)
|
||||
.PARAMETER maxLines
|
||||
Specifies the maximum number of lines to list (24 by default)
|
||||
.PARAMETER speed
|
||||
@ -19,7 +19,7 @@
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$RSS_URL = "https://www.yahoo.com/news/rss", [int]$maxLines = 24, [int]$speed = 10)
|
||||
param([string]$RSS_URL = "https://news.yahoo.com/rss/world", [int]$maxLines = 24, [int]$speed = 10)
|
||||
|
||||
try {
|
||||
[xml]$content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content
|
||||
@ -28,8 +28,8 @@ try {
|
||||
& "$PSScriptRoot/write-typewriter.ps1" "❇️ $($item.title)" $speed
|
||||
if ($count++ -eq $maxLines) { break }
|
||||
}
|
||||
$source = $Content.rss.channel.title
|
||||
$date = $Content.rss.channel.pubDate
|
||||
$source = $content.rss.channel.title
|
||||
$date = $content.rss.channel.pubDate
|
||||
" (by $source as of $date)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
Loading…
Reference in New Issue
Block a user