Skip to content

Instantly share code, notes, and snippets.

@UnableRegister
Last active October 25, 2018 15:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save UnableRegister/4733b04c6a0f19780cbc22cc7237cc66 to your computer and use it in GitHub Desktop.
Save UnableRegister/4733b04c6a0f19780cbc22cc7237cc66 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