3 ms·
Plus if you use curl, it will return JSON instead of HtML
by mazamats 6y ago
Plus if you use curl, it will return JSON instead of HtML
- klohto 6y agocurl ifconfig.co/json
- jodrellblank 6y agoIf you use powershell / invoke-restmethod it will return json and get deserialised into a structured object, too. PS C:\> irm ipinfo.io PS C:\> $x = irm ipinfo.io PS C:\> $x.timezone Europe/London Personally, I use http://checkip.dyndns.org/ http://checkip.dyndns.org/ by habit, with its one-line return.
- majkinetor 6y agoNo it wont, server need to return JSON format itself. Your example doesn't work. It needs to be: irm ipinfo.io/json Your other example can be get like this: irm http://checkip.dyndns.org | % HTML | % body
- JimDabell 6y agoIt will work. The server will return JSON. The URL http://ipinfo.io/ http://ipinfo.io/ returns HTML if the Accept header indicates that you want HTML, and JSON if there is no header, a wildcard header, or a header that requests JSON. As far as I can see, irm doesn’t add an Accept header, so the command jodrellblank provided will fetch JSON and work correctly.
- majkinetor 6y agoDoesnt work on Windows 10 using latest pwsh
- jodrellblank 6y agoWorks on Windows 10 using Windows PowerShell. In Pwsh it does seem to need /json