0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

curl 基本コマンド

0
Last updated at Posted at 2022-01-24

はじめに

 本記事は、プログラミング初学者が、学習を進めていて疑問に思った点について調べた結果を備忘録も兼ねてまとめたものです。
 そのため、記事の内容に誤りが含まれている可能性があります。ご容赦ください。
 間違いを見つけた方は、お手数ですが、ご指摘いただけますと幸いです。

curl 基本コマンド

Terminal
# GETのAPIリクエスト
$ curl http://URL 

# '-s'で終了ステータスのみを表示
$ curl -s http://URL

# '-s'はerror情報も省略するが、'-Ss'はerror情報があれば表示。'-o'で出力先を指定。
$ curl -Ss -o 出力先PATH http://URL 

# '-v'でheader情報も表示
$ curl -v -s http://URL

# '-L'でリダイレクトがあったらリダイレクト先の情報を取る 
$ curl -L http://URL 

# '-X'でHTTPメソッドの指定(指定しなかったらGETになる)
$ curl -X PUT http://URL 

# '--data'でPOSTメソッドでデータを送ることができる
$ curl -X POST --data 'id=xx&name=example' http://URL

# '-I'でHTTPレスポンスヘッダーの取得
$ curl -I http://URL

# jqでjson表示を見やすく
$ curl https://xxx.xxx.com/api/ | jq . 

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?