Last active
January 1, 2016 12:49
-
-
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.
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 '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