Advertisement
Guest User

End and NoMethodError

a guest
Aug 26th, 2015
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.74 KB | None | 0 0
  1. require 'rubygems'
  2. require 'open-uri'
  3. require 'nokogiri'
  4.  
  5. class ImageDownLoad
  6.     def self.checkLink(strLink)
  7.         if (strLink.include?('imgur.com'))
  8.             downloadImgur(strLink)
  9.         else if (strLink.include?('4chan.org'))
  10.             downloadChan(strLink)
  11.         else
  12.             puts "Enter a 4chan or Imgur link"
  13.         end
  14.     end
  15.     def self.downloadImgur(strLink)
  16.        
  17.     end
  18.     def self.downloadChan(strLink)
  19.         page = Nokogiri::HTML(open(strLink))
  20.         img = page.xpath(%Q[//*[@id="f637181555"]/a/@href])
  21.         img.map { |image|  File.write(rand.to_s + '.jpg', open(image).read, {mode: 'wb'})}
  22.     end
  23. end
  24.  
  25. client = ImageDownLoad.new
  26. while (true) do
  27.     puts "Enter URL to rip: "
  28.     strLink = gets.chomp
  29.     if (strLink.include?('break'))
  30.         break
  31.     end
  32.     client.checkLink(strLink)
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement