Batch CURL file inside windows

I am trying to use CURL inside a windows batch file. I need to capture the response inside a variable, but I'm afraid. I've tried several syntaxes and if I try to use curl_setopt I get an undefined error. Back to basics, I started with ...

set response = curl http://www.google.co.uk

      

Any help would be greatly appreciated.

0


source to share


1 answer


@echo off
setlocal disableDelayedExpansion
REM Creating a Newline variable (the two blank lines are required!)
set NLM=^


set NL=^^^%NLM%%NLM%^%NLM%%NLM%

setlocal enableDelayedExpansion
set "response="
for /f "delims=" %%r in ('curl http://www.google.co.uk 2^>^&1') do (
  set response=!response!%NL%%%r 
)
echo %response%
endlocal
endlocal

      



+2


source







All Articles