多行 curl 命令
Multiline curl command
我正在尝试修改使用 Google Chrome 开发工具捕获的 curl 请求。
命令如下所示
curl "http://WEBSITE" -H "Host: WEBSITE" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "Content-Type: multipart/form-data; boundary=---------------------------1184875127259" --data-binary "-----------------------------1184875127259"^
"Content-Disposition: form-data; name=""FORM1"""^
"FORM1DATA"^
"-----------------------------1184875127259"^
"Content-Disposition: form-data; name=""FORM2"""^
"FORM2DATA"^
"-----------------------------1184875127259"^
"Content-Disposition: form-data; name=""FORM3"""^
"FORM3DATA"^
"-----------------------------1184875127259"^
"Content-Disposition: form-data; name=""embed"""^
"true"^
"---------------------------1184875127259--"^
""
Form#
是表单的名称,Form#Data
是我在表单中提交的数据。
我如何将其设为单行 curl 请求,我可以将其复制到我的命令行中并让它执行与我的浏览器相同的操作?
对于 Linux 和 MacOS: 使用 \
转义符:
curl "http://WEBSITE" -H "Host: WEBSITE" \
-H "Accept: text/html,application/xhtml+xml \
,application/xml;q=0.9,*/*;q=0.8"
对于Windows:使用^
转义字符:
curl "http://WEBSITE" -H "Host: WEBSITE" ^
-H "Accept: text/html,application/xhtml+xml ^
,application/xml;q=0.9,*/*;q=0.8"
NOTE: watch out for the tendency to indent on multiple line commands,
as it will embed spaces and screw up the curl command. the sed
command replaces embedded spaces within the variables with the %20
string so that spaces can be used embedded in the strings you pass as
variables
messageout="The rain in Spain stays mainly in the plains"
summaryout="This is a test record"
alertnameout="Test Alert"
curl -v -silent request POST "URL.com?\
summary=`echo $summaryout | sed -e 's/ /%20/g'`&\
alertname=`echo $alertnameout | sed -e 's/ /%20/g'`&\
message=`echo $messageout | sed -e 's/ /%20/g'`"
如果你是 运行宁 Windows,我发现安装 Git 和使用 Git Bash 到 运行 更容易卷曲。这最初是在另一篇文章中提出的:.
相当于\
的Windows是^
。
我正在尝试修改使用 Google Chrome 开发工具捕获的 curl 请求。
命令如下所示
curl "http://WEBSITE" -H "Host: WEBSITE" -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "Content-Type: multipart/form-data; boundary=---------------------------1184875127259" --data-binary "-----------------------------1184875127259"^
"Content-Disposition: form-data; name=""FORM1"""^
"FORM1DATA"^
"-----------------------------1184875127259"^
"Content-Disposition: form-data; name=""FORM2"""^
"FORM2DATA"^
"-----------------------------1184875127259"^
"Content-Disposition: form-data; name=""FORM3"""^
"FORM3DATA"^
"-----------------------------1184875127259"^
"Content-Disposition: form-data; name=""embed"""^
"true"^
"---------------------------1184875127259--"^
""
Form#
是表单的名称,Form#Data
是我在表单中提交的数据。
我如何将其设为单行 curl 请求,我可以将其复制到我的命令行中并让它执行与我的浏览器相同的操作?
对于 Linux 和 MacOS: 使用 \
转义符:
curl "http://WEBSITE" -H "Host: WEBSITE" \
-H "Accept: text/html,application/xhtml+xml \
,application/xml;q=0.9,*/*;q=0.8"
对于Windows:使用^
转义字符:
curl "http://WEBSITE" -H "Host: WEBSITE" ^
-H "Accept: text/html,application/xhtml+xml ^
,application/xml;q=0.9,*/*;q=0.8"
NOTE: watch out for the tendency to indent on multiple line commands, as it will embed spaces and screw up the curl command. the sed command replaces embedded spaces within the variables with the %20 string so that spaces can be used embedded in the strings you pass as variables
messageout="The rain in Spain stays mainly in the plains"
summaryout="This is a test record"
alertnameout="Test Alert"
curl -v -silent request POST "URL.com?\
summary=`echo $summaryout | sed -e 's/ /%20/g'`&\
alertname=`echo $alertnameout | sed -e 's/ /%20/g'`&\
message=`echo $messageout | sed -e 's/ /%20/g'`"
如果你是 运行宁 Windows,我发现安装 Git 和使用 Git Bash 到 运行 更容易卷曲。这最初是在另一篇文章中提出的:.
相当于\
的Windows是^
。