-
-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathlist-news.ps1
More file actions
executable file
·42 lines (39 loc) · 1.27 KB
/
list-news.ps1
File metadata and controls
executable file
·42 lines (39 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<#
.SYNOPSIS
Lists the latest news
.DESCRIPTION
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 (default: New York Times)
.EXAMPLE
PS> ./list-news.ps1
TIME HEADLINES (source: https://www.nytimes.com/section/world)
---- ---------
09:15 Deadly Mediterranean wildfires kill more than 40
...
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$RSS_URL = "https://rss.nytimes.com/services/xml/rss/nyt/World.xml")
try {
[xml]$content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content
$title = $content.rss.channel.title
$URL = $content.rss.channel.link
Write-Host "`n TIME HEADLINES (source: " -noNewline
Write-Host $URL -foregroundColor blue -noNewline
Write-Host ")"
Write-Host " ---- ---------"
[int]$count = 1
foreach ($item in $content.rss.channel.item) {
$title = $item.title -replace "â","'"
$time = $item.pubDate.Substring(16, 6)
& "$PSScriptRoot/write-typewriter.ps1" "$time $title" 3
Start-Sleep -milliseconds 700
}
exit 0 # success
} catch {
"⚠️ ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
exit 1
}