-
-
Save rmoriz/184585 to your computer and use it in GitHub Desktop.
nokogiri
This file contains 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
require 'nokogiri' | |
require 'open-uri' | |
require 'tempfile' | |
image_url = Nokogiri::HTML(open('http://api.cheezburger.com/xml/category/cats/lol/random')).xpath('/html/body/lol/lolimageurl').first.content | |
file = Tempfile.new('lolcat.jpg') | |
file.write(open('image_url') | |
file.close | |
system "osascript <<END\ntell application \"Finder\"\n set desktop picture to POSIX file \"#{file.path}\"\n end tell\nEND" | |
# irb(main):016:0> file | |
# => #<File:/var/folders/6X/6XMsqrRsGZO8vdOp-8J6oE+++TI/-Tmp-/lolcat.jpg20090910-52471-ve2l0x-0> | |
# irb(main):017:0> system "osascript <<END\ntell application \"Finder\"\n set desktop picture to POSIX file \"#{file.path}\"\n end tell\nEND" | |
# 2009-09-10 16:49:53.018 osascript[52494:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: # dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: | |
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper | |
# osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers. | |
# => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment