Skip to content

Instantly share code, notes, and snippets.

@liubin
Last active January 1, 2016 12:49
Show Gist options
  • Save liubin/8147259 to your computer and use it in GitHub Desktop.
Save liubin/8147259 to your computer and use it in GitHub Desktop.
download slide images from slideshare.net to a local folder. Without exception check.
require 'hpricot'
require 'open-uri'
require 'fileutils'
# usage:
# ruby ss.rb SLIDESHARE.NET/XXX/YYY/ZZZ
folder = ARGV[0].split('/').last
FileUtils.mkdir folder
doc = open(ARGV[0]) { |f| Hpricot(f) }
(doc/"img.slide_image").each{ |e|
location = e.attributes['data-full']
img = location.split('/').last.split('?').first
File.open("#{folder}/#{img}", 'wb') do |fo|
fo.write open(location).read
end
puts "got #{location}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment