簡體   English   中英

窗口批處理文件中的CURL

[英]CURL inside windows batch file

我正在嘗試在Windows批處理文件中使用CURL。 我需要在變量中捕獲響應,但我正在努力。 我嘗試了幾種語法,如果我嘗試使用curl_setopt,我會得到一個關於未定義的Environment變量的錯誤。 回到基礎,我開始......

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

任何幫助將不勝感激。

@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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM