“Curl”的版本间的差异
跳到导航
跳到搜索
Jihongchang(讨论 | 贡献) |
Jihongchang(讨论 | 贡献) (→参数说明) |
||
(未显示同一用户的5个中间版本) | |||
第1行: | 第1行: | ||
+ | === 参考 === | ||
https://www.ruanyifeng.com/blog/2019/09/curl-reference.html | https://www.ruanyifeng.com/blog/2019/09/curl-reference.html | ||
+ | |||
+ | https://4sysops.com/archives/how-to-use-curl-on-windows/#rtoc-3 | ||
+ | |||
+ | https://www.booleanworld.com/curl-command-tutorial-examples/ | ||
+ | |||
=== 安装 === | === 安装 === | ||
第20行: | 第26行: | ||
==== Windows ==== | ==== Windows ==== | ||
+ | https://curl.se/windows/ | ||
− | === | + | |
+ | === 使用示例 === | ||
+ | [[Curl 使用示例]] | ||
==== Linux 版 ==== | ==== Linux 版 ==== | ||
第42行: | 第51行: | ||
--output - | --output - | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | |||
==== Windows 版 ==== | ==== Windows 版 ==== | ||
第61行: | 第72行: | ||
--output - | --output - | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
Windows 多行命令用 ^ 换行,Linux 里用 \ 换行; | Windows 多行命令用 ^ 换行,Linux 里用 \ 换行; | ||
+ | |||
+ | --output 后面跟文件路径,指示将响应内容输出到文件;当后面跟 - 的时候表示无论如何(即使是非文本的二进制文件)输出到控制台中。 | ||
+ | |||
+ | Linux 中 --header 后面的参数使用 '(单引号)包裹,Windows 中用 "(双引号)包裹,且对字符串中的双引号加以转义。 | ||
+ | |||
+ | |||
+ | |||
+ | |||
=== 参数说明 === | === 参数说明 === | ||
第75行: | 第95行: | ||
-s 和 -sS 不是一个意思 | -s 和 -sS 不是一个意思 | ||
+ | |||
+ | |||
-s/--silent | -s/--silent | ||
Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute. | Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute. | ||
+ | 不显示进度条 | ||
+ | |||
+ | |||
-S/--show-error | -S/--show-error | ||
When used with -s it makes curl show an error message if it fails. | When used with -s it makes curl show an error message if it fails. |
2023年2月4日 (六) 06:05的最新版本
参考
https://www.ruanyifeng.com/blog/2019/09/curl-reference.html
https://4sysops.com/archives/how-to-use-curl-on-windows/#rtoc-3
https://www.booleanworld.com/curl-command-tutorial-examples/
安装
Linux
apk 安装
~ # apk add curl
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
(1/4) Installing brotli-libs (1.0.9-r6)
(2/4) Installing nghttp2-libs (1.47.0-r0)
(3/4) Installing libcurl (7.83.1-r2)
(4/4) Installing curl (7.83.1-r2)
Executing busybox-1.35.0-r13.trigger
OK: 12 MiB in 21 packages
~ #
Windows
使用示例
Linux 版
curl --location --request GET 'https://www.douyin.com/user/abcd' \
--header 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
--header 'accept-encoding: gzip, deflate, br' \
--header 'accept-language: en' \
--header 'cache-control: max-age=0' \
--header 'referer: https://www.douyin.com/user/abcd' \
--header 'sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "Windows"' \
--header 'sec-fetch-dest: document' \
--header 'sec-fetch-mode: navigate' \
--header 'sec-fetch-site: same-origin' \
--header 'upgrade-insecure-requests: 1' \
--header 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
--output -
Windows 版
curl --location --request GET "https://www.douyin.com/user/abcd" ^
--header "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" ^
--header "accept-encoding: gzip, deflate, br" ^
--header "accept-language: en" ^
--header "cache-control: max-age=0" ^
--header "referer: https://www.douyin.com/user/abcd" ^
--header "sec-ch-ua: \"Not?A_Brand\";v=\"8\", \"Chromium\";v=\"108\", \"Google Chrome\";v=\"108\"" ^
--header "sec-ch-ua-mobile: ?0" ^
--header "sec-ch-ua-platform: \"Windows\"" ^
--header "sec-fetch-dest: document" ^
--header "sec-fetch-mode: navigate" ^
--header "sec-fetch-site: same-origin" ^
--header "upgrade-insecure-requests: 1" ^
--header "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" ^
--output -
Windows 多行命令用 ^ 换行,Linux 里用 \ 换行;
--output 后面跟文件路径,指示将响应内容输出到文件;当后面跟 - 的时候表示无论如何(即使是非文本的二进制文件)输出到控制台中。
Linux 中 --header 后面的参数使用 '(单引号)包裹,Windows 中用 "(双引号)包裹,且对字符串中的双引号加以转义。
参数说明
-o 和 -O 不是一个意思
-O, --remote-name Write output to a file named as the remote file
-o, --output <file> Write to file instead of stdout
--output-dir <dir> Directory to save files in
-s 和 -sS 不是一个意思
-s/--silent
Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute.
不显示进度条
-S/--show-error
When used with -s it makes curl show an error message if it fails.
参数区分大小写
-L, --location Follow redirects(3xx)