mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-17 02:01:01 +01:00
Updated watch-news.ps1
This commit is contained in:
parent
142f14bb44
commit
8bf0a8e8f0
@ -5,8 +5,10 @@
|
|||||||
This PowerShell script lists the latest headlines by using a RSS (Really Simple Syndication) feed.
|
This PowerShell script lists the latest headlines by using a RSS (Really Simple Syndication) feed.
|
||||||
.PARAMETER RSS_URL
|
.PARAMETER RSS_URL
|
||||||
Specifies the URL to the RSS feed (Yahoo World News by default)
|
Specifies the URL to the RSS feed (Yahoo World News by default)
|
||||||
|
.PARAMETER lines
|
||||||
|
Specifies the initial number of headlines
|
||||||
.PARAMETER timeInterval
|
.PARAMETER timeInterval
|
||||||
Specifies the time interval in millisec between the Web requests
|
Specifies the time interval in seconds between the Web requests
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./watch-news.ps1
|
PS> ./watch-news.ps1
|
||||||
❇️ Niger coup: Ecowas deadline sparks anxiety in northern Nigeria ❇️
|
❇️ Niger coup: Ecowas deadline sparks anxiety in northern Nigeria ❇️
|
||||||
@ -16,7 +18,7 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([string]$RSS_URL = "https://news.yahoo.com/rss/world", [int]$timeInterval = 30000) # in ms
|
param([string]$RSS_URL = "https://news.yahoo.com/rss/world", [int]$lines = 10, [int]$timeInterval = 30) # in seconds
|
||||||
|
|
||||||
function PrintLatestHeadlines([string]$previous, [int]$maxLines) {
|
function PrintLatestHeadlines([string]$previous, [int]$maxLines) {
|
||||||
[xml]$content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content
|
[xml]$content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content
|
||||||
@ -37,8 +39,8 @@ function PrintLatestHeadlines([string]$previous, [int]$maxLines) {
|
|||||||
try {
|
try {
|
||||||
$latest = ""
|
$latest = ""
|
||||||
while ($true) {
|
while ($true) {
|
||||||
$latest = PrintLatestHeadlines $latest 10
|
$latest = PrintLatestHeadlines $latest $lines
|
||||||
Start-Sleep -milliseconds $timeInterval
|
Start-Sleep -seconds $timeInterval
|
||||||
}
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user