“Curl”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
第2行: 第2行:
  
 
=== 安装 ===
 
=== 安装 ===
 +
 +
==== Linux ====
 +
 +
===== apk 安装 =====
 
<syntaxhighlight lang="shell-session">
 
<syntaxhighlight lang="shell-session">
 
~ # apk add curl
 
~ # apk add curl
第15行: 第19行:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
+
==== 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)
 
  
  
第60行: 第40行:
 
--header 'upgrade-insecure-requests:  1' \
 
--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'
 
--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 -
 
</syntaxhighlight>
 
</syntaxhighlight>
  
第83行: 第64行:
  
 
Windows 多行命令用 ^ 换行,Linux 里用 \ 换行;
 
Windows 多行命令用 ^ 换行,Linux 里用 \ 换行;
 +
 +
=== 参数说明 ===
 +
-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)

2023年2月2日 (四) 13:45的版本

https://www.ruanyifeng.com/blog/2019/09/curl-reference.html

安装

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 里用 \ 换行;

参数说明

-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)