Last active
December 26, 2015 21:29
-
-
Save joshuaswilcox/7216225 to your computer and use it in GitHub Desktop.
Get latest Calvin and Hobbes comic and save to folder
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 ruby | |
require 'nokogiri' | |
require 'net/http' | |
require 'open-uri' | |
require 'cgi' | |
require "fileutils" | |
# folder where to save the comic to | |
$basedir = '~/Documents/geeklets/ch_comic' | |
def get_comic | |
response = Nokogiri::HTML(open("http://www.gocomics.com/calvinandhobbes")) | |
comic_img = response.css('div#content div.feature p.feature_item a img')[0]['src'] | |
File.open('/Users/josh/Documents/geeklets/ch_comic/comic.gif', "wb") do |file| | |
file.write open("#{comic_img}").read | |
end | |
end | |
get_comic |
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
/Users/#{YOUR_USERNAME}/.rvm/rubies/#{YOUR_RUBY_VERSION} > /dev/null | |
/Users/#{YOUR_USERNAME}/.rvm/rubies/#{YOUR_RUBY_VERSION}/bin/ruby ~/Documents/geeklets/geek_ch.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment