Created
December 2, 2009 10:21
-
-
Save mgunneras/247112 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Run as cronjob to have a daily fresh desktop | |
# background from the NASA Image of the day gallery. | |
# You might need to install BeautifulSoup and appscript | |
# easy_install BeautifulSoup appscript | |
from os.path import basename | |
from BeautifulSoup import BeautifulStoneSoup | |
from appscript import app, mactypes | |
from urllib2 import urlopen | |
rss_url = 'http://www.nasa.gov/rss/lg_image_of_the_day.rss' | |
image_url = BeautifulStoneSoup(urlopen(rss_url).read()).find('url').string | |
image_path = "/%s" % basename(image_url) | |
open(image_path, 'w').write(urlopen(image_url).read()) | |
app('Finder').desktop_picture.set(mactypes.File(image_path)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment