Created
November 1, 2010 07:41
-
-
Save colby/657791 to your computer and use it in GitHub Desktop.
Connects to simpledesktops.com and grabs a random image to assign as your profiles desktop image.
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
| import random | |
| import urllib | |
| import urllib2 | |
| import tempfile | |
| import subprocess | |
| from appscript import app, mactypes | |
| import lxml.html as lh | |
| url = "http://simpledesktops.com/browse/" | |
| random_page = str(random.randint(1,20)) | |
| random_image = str(random.randint(1,29)) | |
| website = urllib2.urlopen(url + random_page) | |
| parse = lh.parse(website) | |
| link = parse.xpath("//div[@class='desktop']/a") | |
| grab_image = link[1].get('href') | |
| set_desktop = tempfile.mkstemp() | |
| urllib.urlretrieve(grab_image, set_desktop[1]) | |
| app('Finder').desktop_picture.set(mactypes.File(set_desktop[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment