News for hackers. Stuff that matters.
Re:Two Months with Powershell on a Unix by earthboundkid on Thursday April 23, 2020 @09:37PM (#22963745)
FWIW, I already have a command line tool that can do that installed in regular Unix: https://github.com/ericchiang/pup The docs even use the same example of scraping HN.

How does Invoke-WebRequest decide if it’s looking at HTML or something else?

Re:Two Months with Powershell on a Unix by jve on Thursday April 23, 2020 @09:53PM (#22963830)
Well, you use Invoke-RestMethod for JSON/XML stuff.

Or decide yourself for Invoke-WebRequest to pipe it with whatever the data: ConvertFrom-{JSON,XML,CSV}

With Invoke-WebRequest you get back headers, raw response, etc - and you get to decide whats next. With the RestMethod - just the content as an object.

Re:Two Months with Powershell on a Unix by ct520 on Friday April 24, 2020 @12:35AM (#22964685)
There is an param to declare response type parsing and if you want to use different parsing. Older versions of powershell use IE and webrequest will randomly barf. It really sucked. You can also use a rest request method that uses json.net to deserialize I believe .