Skip to content

Instantly share code, notes, and snippets.

@zxhfighter
Last active December 25, 2019 10:42
Show Gist options
  • Save zxhfighter/7313445 to your computer and use it in GitHub Desktop.
Save zxhfighter/7313445 to your computer and use it in GitHub Desktop.
curl 命令

curl 命令

如果你再*nix机器下,运行man curl命令查看具体的使用用法。

curl 简介

curl is a tool to transfer data from or to a server, using one of the supported protocols (http, https, ftp, ftps...). The command is designed to work without user interaction.

curl offers a busload of useful tricks like proxy support, user authentication, ftp upload, http post, ssl connections, cookies, file transfer resum and more.

curl 语法

curl [options] [URL...]

curl 实例

// 查看请求信息
curl -I www.baidu.com

// 批量
curl http://(tieba, fm, zhidao).baidu.com/
curl http://sports.tumblr.com/page/[5-10]

// GET请求
curl 'www.a.com/junk.cgi?name1=value1&name2=value2'

// POST请求
curl -d 'name=value1&password=pass1' www.a.com/junk.cgi

// 上传文件
curl -F upload=@localfilename -F press=OK [URL]

//保存页面
curl http://www.yahoo.com > page.html
curl -o page.html http://www.yahoo.com

//批量下载图片
curl -O http://cgi2.tky.3web.ne.jp/~zzh/screen[1-10].JPG
curl -o #2_#1.jpg http://cgi2.tky.3web.ne.jp/~{zzh,nick}/[001-201].JPG

//验证
curl -u name:password www.secrets.com

//代理
curl -U proxyuser:proxypassword http://curl.haxx.se
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment