Add '-useBasicParsing'

This commit is contained in:
Markus Fleschutz 2021-12-02 15:39:50 +01:00
parent a54455d581
commit 755f797bce
5 changed files with 5 additions and 5 deletions

View File

@ -16,7 +16,7 @@
param([string]$location = "") # empty means determine automatically
try {
$Weather = (Invoke-WebRequest http://wttr.in/${location}?format=j1 -UserAgent "curl" ).Content | ConvertFrom-Json
$Weather = (Invoke-WebRequest http://wttr.in/${location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json
$Temp = $Weather.current_condition.temp_C
$Precip = $Weather.current_condition.precipMM

View File

@ -15,7 +15,7 @@ $Cities="Hawaii","Los Angeles","Mexico City","Miami","New York","Rio de Janeiro"
try {
foreach($City in $Cities) {
$Line = (Invoke-WebRequest http://wttr.in/${City}?format="%c %l+%t+%p+%h+%P+%w +%S →+%s" -UserAgent "curl").Content
$Line = (Invoke-WebRequest http://wttr.in/${City}?format="%c %l+%t+%p+%h+%P+%w +%S →+%s" -UserAgent "curl" -useBasicParsing).Content
"$Line"
}
exit 0 # success

View File

@ -12,7 +12,7 @@
#>
try {
(Invoke-WebRequest http://wttr.in/Moon -UserAgent "curl" ).Content
(Invoke-WebRequest http://wttr.in/Moon -userAgent "curl" -useBasicParsing).Content
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -16,7 +16,7 @@
param([string]$GeoLocation = "") # empty means determine automatically
try {
(invoke-webRequest http://v2d.wttr.in/$GeoLocation -UserAgent "curl" ).Content
(invoke-webRequest http://v2d.wttr.in/$GeoLocation -userAgent "curl" -useBasicParsing).Content
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -16,7 +16,7 @@
param([string]$GeoLocation = "") # empty means determine automatically
try {
(invoke-webRequest http://wttr.in/$GeoLocation -UserAgent "curl" ).Content
(Invoke-WebRequest http://wttr.in/$GeoLocation -userAgent "curl" -useBasicParsing).Content
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"