Skip to content

Instantly share code, notes, and snippets.

@ryonsherman
Last active August 29, 2015 13:57
Show Gist options
  • Save ryonsherman/9652341 to your computer and use it in GitHub Desktop.
Save ryonsherman/9652341 to your computer and use it in GitHub Desktop.
Bing wallpaper downloader
#!/usr/bin/env sh
LOC="en-US"
for RES in _1920x1200 _1366x768 _1280x720 _1024x768; do
XML="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=${LOC}"
URL="http://www.bing.com$(echo $(curl -s ${XML}) | grep -oP "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)${RES}.jpg"
IMG=${URL##*/}
curl -s -o /tmp/$IMG $URL
file /tmp/$IMG | grep -i HTML && rm -rf /tmp/$IMG && continue
break
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment