wget and curl examples

wget and curl examples

  • You may easily automate data retrieval through a shell script. This will download a piece of data into file mydata.mseed:

# using wget
wget "http://ws.resif.fr/fdsnws/dataselect/1/query?network=ZH&starttime=2003-06-01T00:00:00&endtime=2003-07-01T00:00:00" -O mydata.mseed
# using curl
curl -o mydata.mseed "http://ws.resif.fr/fdsnws/dataselect/1/query?network=ZH&starttime=2003-06-01T00:00:00&endtime=2003-07-01T00:00:00"


  • You may use special options to let the server propose a name for the received file:
# using wget
wget --content-disposition "http://ws.resif.fr/fdsnws/station/1/query?format=xml&level=network&network=RD"
# using curl
curl --remote-name --remote-header-name "http://ws.resif.fr/fdsnws/station/1/query?format=xml&level=network&network=RD"


  • Another script example, downloading latest 24h data for channel FR.OGDI.HHZ (GNU date needed):
yesterday=`date --date="yesterday" --utc +"%Y-%m-%dT%H:%M:%S"`
now=`date --utc +"%Y-%m-%dT%H:%M:%S"`
url="http://ws.resif.fr/fdsnws/dataselect/1/query?network=FR&station=OGDI&channel=HHZ&starttime=$yesterday&endtime=$now"
# using wget
wget $url -O last24h.miniseed
# using curl
curl -o last24h.miniseed $url


  • wget, curl and queryauth (restricted data access):
wget --http-user=mylogin --http-password=mypassword "http://ws.resif.fr/fdsnws/dataselect/1/queryauth?network=YV&station=EURO&starttime=2011-12-01&endtime=2011-12-02" -O mydata.miniseed
curl --digest --user "mylogin:mypassword" -o mydata.mseed  "http://ws.resif.fr/fdsnws/dataselect/1/queryauth?network=YV&station=EURO&starttime=2011-10-01&endtime=2011-10-02"

 

  • using wget and POST method, with request file request.txt as:
quality=B
YV EURO * * 2012-08-02T09:38:00 2012-08-02T10:18:00
YV EURO * * 2013-02-08T15:26:00 2013-02-08T16:06:00
YV EURO * * 2013-02-09T14:16:00 2013-02-09T14:56:00

  • then querying with appropriate login/password, using wget or curl:
# using wget
wget --post-file=request.txt  --http-user=mylogin --http-password=mypassword http://ws.resif.fr/fdsnws/dataselect/1/queryauth -O mydata.miniseed
# using curl
curl --digest --user "mylogin:mypassword" -o mydata.mseed --data-binary @request.txt http://ws.resif.fr/fdsnws/dataselect/1/queryauth

 

Search