curl

出自Gea-Suan Lin's Wiki
跳至導覽 跳至搜尋

curl是一套工具,包括library以及command line tool。

範例

JSON

如果要POST JSON的話:

curl -v -X POST -H 'Content-Type: application/json' -d '{"a":"b","c":"d"}' https://httpbin.org/anything

File Upload

上傳檔案:

curl -v -X POST -F "foo=@/home/foo/bar.png" https://httpbin.org/anything

Proxy

指定proxy可以用--proxy並且包含proxy需要的帳號密碼:

curl -v --proxy https://username:password@proxy.example.com:4128/ https://httpbin.org/anything

Request Header

指定referer可以用-H

curl -v -H "Referer: https://www.example.com/" https://httpbin.org/anything

指定User-agent可以使用-A

curl -v -A "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" https://httpbin.org/anything

外部連結