curl 的一些用法

  1. curl -o|--output $filename www.baidu.com 或 curl www.baidu.com > filename # 保存网页至filename

  2. curl -O|--remote-name $url # e.g. curl -O http://www.etao.com/sitemap.xml -O http://www.amazon.com/robots.txt

  3. curl -I|--head baidu.com # 发送 HEAD 方法给 http server, 显示 header 信息

  4. curl -i|--include $url # 输出中包含 HTTP-header 信息

  5. curl -D|--dump_header $filename $url # 把 response header 信息写入文件

  6. curl -L|--location jd.com # follow redirect

  7. curl -A|--user-agent "[User Agent]" baidu.com # 设置User Agent

  8. curl -e|--referer $referer $url # 设置 $referer

  9. curl -b|--cookie "NAME1=VALUE1; NAME2=VALUE2" $url # 设置 cookie

  10. curl -H|--header 'Content-type:application/xml' $url # 设置 request header 信息

  11. curl -v|--verbose $url # curl HTTP 详情

  12. curl -x|--proxy <[protocol://][user@password]proxyhost[:port]>

    # This option overrides existing environment variables that set the proxy to use. If there's an environment variable setting a proxy, you can set proxy to "" to override it.

  13. curl --socks5 127.0.0.1:7070

POST
  1. curl -X|--request # e.g: curl -X POST

  2. curl --data-binary @$file|$str $url # to post data purely binary, post $url $file or $str

  3. curl -d|--data|--data-ascii @$file|$str $url # post $url $file or $str

  4. curl --data-urlencode @$file|$str $url # (HTTP) similar to the other --data options with the exception that this performs URL-encoding.

  5. curl -F|--form # POST data 使用 Content-Type multipart/form-data.

    e.g: curl -F password=@/etc/passwd www.foo.com

    e.g: curl -F "web=@index.html;type=text/html" www.foo.com

    e.g: curl -F "file=@localfile;filename=nameinpost" www.foo.com

    e.g: curl -F file=@file1 -F file=@file2 www.foo.com

如何给curl添加代理
vi .curlrc
添加socks5 = "127.0.0.1:1080"

Liunx

这篇文章: 有用 无用
创建 2014-02-25 07:50:35 / 更新 2017-02-07 14:59:38