LoginSignup
2
1

More than 5 years have passed since last update.

curlでパラメータを送信する方法

Posted at

curlで、Webサイトのページを取得する際に、パラメータを指定したい場合の(ひとつの)方法。
具体的には、-dオプションで、パラメータをつなげる。

例は、interfmのmusic searchで、3時間前から今までのプレイリストを取得する場合のリクエスト方法

html=aaa.html
fyear=`date --date '3 hours ago' +"%Y"`
fmonth=`date --date '3 hours ago' +"%m"`
fday=`date --date '3 hours ago' +"%d"`
fhour=`date --date '3 hours ago' +"%H"`

tyear=`date +"%Y"`
tmonth=`date +"%m"`
tday=`date +"%d"`
thour=`date +"%H"`

curl -d "fyear=${fyear}" -d "tyear=${tyear}" -d "fmonth=${fmonth}" -d "tmonth=${tmonth}" -d "fday=${fday}" -d "tday=${tday}" -d "fhour=${fhour}" -d "thour=${thour}" -d "fminute=0" -d "tminute=59" -o ${html} http://www.interfm.co.jp/search/index.php
2
1
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
2
1