Skip to content

Instantly share code, notes, and snippets.

@ErwanDavid
Last active September 29, 2023 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErwanDavid/0cd241fc81e5b1d51c1ffa86c531887e to your computer and use it in GitHub Desktop.
Save ErwanDavid/0cd241fc81e5b1d51c1ffa86c531887e to your computer and use it in GitHub Desktop.
Get Astronomy Photo of the Day from the NASE (need jq)
start='2018-01-01'
end='2022-02-01'
key='your sevret key' # see https://api.nasa.gov/
start=$(date -d $start +%Y%m%d)
end=$(date -d $end +%Y%m%d)
while [[ $start -le $end ]]
do
curDate=$(date -d $start +%Y-%m-%d)
echo $curDate
curl "https://api.nasa.gov/planetary/apod?api_key=$key&date=$curDate"
wget `curl "https://api.nasa.gov/planetary/apod?api_key=$key&date=$curDate" | jq .url | tr -d '"'`
start=$(date -d"$start + 1 day" +"%Y%m%d")
sleep 5
done
@ErwanDavid
Copy link
Author

The goal is to download automatically all the picture of the APOD https://apod.nasa.gov/apod/
You need to create an API key (free)
You need curl and jq (and a shell ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment