您的位置:首页 > 其它

curl 命令

2015-12-30 18:39 387 查看

get request

curl "param1=value1¶m2=value2" http://www.xxx.com[/code] 

post request

curl -d "param1=value1¶m2=value2" http://www.xxx.com[/code]-d/--data <data>

输出至文件时不输出统计信息

当将结果输出至文件或重定向至文件时,会出现如下统计信息:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed

0     0    0     0    0     8      0   5637 --:--:-- --:--:-- --:--:--  5637
0     0    0     0    0     8      0      7 --:--:--  0:00:01 --:--:--     0
0    41    0    41    0     8     26      5 --:--:--  0:00:01 --:--:--    21
0    41    0    41    0     8     26      5 --:--:--  0:00:01 --:--:--    21

通过 -s/--silent 关闭

上传文件

-F/--form <name=content>

curl -F "file=@xxx.zip" http://xxx.com/uploadfile?xxx=123456 curl -F "file=@localfile;filename=nameinpost" url.com

其它常用选项

--connect-timeout <seconds>: 建立连接超时时间

-m/--max-time <seconds>: 操作超时时间

-H/--header <header>: 指定 HTTP header, 如果不指定,将使用 curl 默认头。其中 User-Agent 和 Referer 也可以通过 -A/--user-agent and -e/--referer 来指定。

-v/--verbose: 显示详细信息,如请求和响应。

-X/--request <command>: 指定 HTTP method

-i, --include: (HTTP)  Include  the  HTTP-header  in the output

-I, --head: (HTTP/FTP/FILE) Fetch the HTTP-header only
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: