Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created August 26, 2015 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/88392f527df3774c41e1 to your computer and use it in GitHub Desktop.
Save anonymous/88392f527df3774c41e1 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'open-uri'
require 'nokogiri'
class ImageDownLoad
def self.checkLink(strLink)
if (strLink.include?('imgur.com'))
downloadImgur(strLink)
else if (strLink.include?('4chan.org'))
downloadChan(strLink)
else
puts "Enter a 4chan or Imgur link"
end
end
def self.downloadImgur(strLink)
end
def self.downloadChan(strLink)
page = Nokogiri::HTML(open(strLink))
img = page.xpath(%Q[//*[@id="f637181555"]/a/@href])
img.map { |image| File.write(rand.to_s + '.jpg', open(image).read, {mode: 'wb'})}
end
end
client = ImageDownLoad.new
while (true) do
puts "Enter URL to rip: "
strLink = gets.chomp
if (strLink.include?('break'))
break
end
client.checkLink(strLink)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment