Hacker News new | ask | show | jobs
by acz 3718 days ago
For PowerShell: (Invoke-WebRequest wttr.in/Brussels).AllElements | ?{$_.tagname -eq "pre"} | Select-Object -ExpandProperty outerText
2 comments

Or a bit shorter:

    ((iwr wttr.in/Brussels).AllElements | ? tagname -eq pre).outerText
We could also wrap it into a function:

    function Get-Weather($Location){((iwr wttr.in/$Location).AllElements | ? tagname -eq pre).outerText}
Or you could just set/unset all the right headers and get the ASCII art directly (as `curl wttr.in/{location}` does)

Although you'll need to interpret or strip the color codes.

There is a hack to make PowerShell print vt100 colours http://www.nivot.org/blog/post/2016/02/04/Windows-10-TH2-%28...

Doesn’t work for me, but works for others it seems.