mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-22 09:58:19 +02:00
Updated list-news.ps1
This commit is contained in:
parent
c9961fe97d
commit
0537d616ee
@ -11,6 +11,7 @@
|
|||||||
Specifies the speed to write the text (10 ms by default)
|
Specifies the speed to write the text (10 ms by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./list-news.ps1
|
PS> ./list-news.ps1
|
||||||
|
<UTC> <Source: https://www.yahoo.com/news/world>
|
||||||
❇️ 09:15 Deadly Mediterranean wildfires kill more than 40
|
❇️ 09:15 Deadly Mediterranean wildfires kill more than 40
|
||||||
...
|
...
|
||||||
.LINK
|
.LINK
|
||||||
@ -23,6 +24,11 @@ param([string]$RSS_URL = "https://news.yahoo.com/rss/world", [int]$maxLines = 24
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
[xml]$content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content
|
[xml]$content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content
|
||||||
|
|
||||||
|
$URL = $content.rss.channel.link
|
||||||
|
""
|
||||||
|
" [UTC] [SOURCE: $URL]"
|
||||||
|
|
||||||
[int]$count = 1
|
[int]$count = 1
|
||||||
foreach ($item in $content.rss.channel.item) {
|
foreach ($item in $content.rss.channel.item) {
|
||||||
$title = $item.title
|
$title = $item.title
|
||||||
@ -30,8 +36,6 @@ try {
|
|||||||
& "$PSScriptRoot/write-typewriter.ps1" "❇️ $time $title" $speed
|
& "$PSScriptRoot/write-typewriter.ps1" "❇️ $time $title" $speed
|
||||||
if ($count++ -eq $maxLines) { break }
|
if ($count++ -eq $maxLines) { break }
|
||||||
}
|
}
|
||||||
$URL = $content.rss.channel.link
|
|
||||||
" <UTC> <Read more at: $URL>"
|
|
||||||
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