Skip to content

Instantly share code, notes, and snippets.

@chuanxd
Forked from UnableRegister/curl.md
Created October 25, 2018 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuanxd/fc768d5900360ea93b91152161e2d0a7 to your computer and use it in GitHub Desktop.
Save chuanxd/fc768d5900360ea93b91152161e2d0a7 to your computer and use it in GitHub Desktop.
curl #curl

CURL

查看网页源码

curl url

保存

  • curl -o [文件名] url

自动跳转

curl -L url

显示头信息

curl -i url

发送表单信息

get

  • curl example.com?data=xxx

post

  • x-www-url-encoded
    • curl -X POST -d '{"data": 1}' [URL]
  • applocation/json
    • curl -X POST -d "key=value" [URL}

multipart/form-data

  • curl -F "key=calue" [URL]

文件

  • curl -F "key=@value" [URL]

HTTP动词

curl -X [POST | DELETE]

显示通信过程

curl -v url

curl --trace output.txt url

curl --trace-ascii output.txt url

Referer字段

curl --referer http://example.com [URL]

User Agent

curl --user-agent [User Agent] [URL]

cookie

curl --cookie "name=xxx" [URL]

保存

  • curl -c cookies [URL]
  • curl -b cookies [URL]

Header

curl -h [header] [URL]

HTTP 认证

curl -u [name:password] [URL]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment