79235677

Date: 2024-11-29 02:15:29
Score: 2.5
Natty:
Report link

Cannot really visit that api.ipify.org website, but I guess this task is essentially visit a URL that response json, and get a field out of it. Here is an example using curl and common string-splitting-and-matching techniques in batch script. You might need to adjust the tokens to match the sequence of response. I tested with one of my local REST service and it's fine.

@echo off
FOR /F "tokens=2 delims=:{}" %%A IN ('curl -s "https://api.ipify.org?format=json" ^| findstr "ip"') DO SET IP=%%A

SET IP=%IP:"=%

echo %IP%

pause

That being said, this is pure pain, and the method is certainly not robust. Is calling powershell from batch an option? like the accepted answer in this question.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Starts with a question (0.5): Cannot
  • Low reputation (1):
Posted by: Cobalt Rimbo