curl用法获取标题

Ank*_*wal 45 linux curl

为什么这不起作用:

curl -X HEAD http://www.google.com
Run Code Online (Sandbox Code Playgroud)

但这些都很好用:

curl -I http://www.google.com

curl -X GET http://www.google.com
Run Code Online (Sandbox Code Playgroud)

dmc*_*c7z 80

您需要将-i标志添加到第一个命令,以在输出中包含HTTP标头.这是打印标题所必需的.

curl -X HEAD -i http://www.google.com
Run Code Online (Sandbox Code Playgroud)

更多信息:https://serverfault.com/questions/140149/difference-between-curl-i-and-curl-x-head


bov*_*der 30

curl --head https://www.example.net

卷曲本身就是我指出的; 当我发出命令时-X HEAD,它打印出来:

Warning: Setting custom HTTP method to HEAD with -X/--request may not work the 
Warning: way you want. Consider using -I/--head instead.
Run Code Online (Sandbox Code Playgroud)

  • 有关消息的说明,请参阅 https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/。 (2认同)