forked from fleschutz/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-headlines.ps1
More file actions
32 lines (30 loc) · 835 Bytes
/
Copy pathcheck-headlines.ps1
File metadata and controls
32 lines (30 loc) · 835 Bytes
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
<#
.SYNOPSIS
Checks the latests headlines
.DESCRIPTION
This script tells the latest headlines by text-to-speech (TTS).
.PARAMETER RSS_URL
Specifies the URL to the RSS feed
.PARAMETER MaxCount
Specifies the number of news to list
.EXAMPLE
PS> ./list-news
.NOTES
Author: Markus Fleschutz · License: CC0
.LINK
https://github.com/fleschutz/PowerShell
#>
param([string]$RSS_URL = "https://yahoo.com/news/rss/world", [int]$MaxCount = 8)
try {
[xml]$Content = (invoke-webRequest -uri $RSS_URL -useBasicParsing).Content
[int]$Count = 0
foreach ($item in $Content.rss.channel.item) {
& "$PSScriptRoot/give-reply.ps1" "$($item.title)"
$Count++
if ($Count -eq $MaxCount) { break }
}
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}