Module: RandomImages::Images
- Defined in:
- lib/random_images.rb
Class Method Summary collapse
Class Method Details
.get(number = 100, keyword = "me", content = "face") ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/random_images.rb', line 9 def self.get(number = 100, keyword = "me", content = "face") max = [number / 10, 1].max nokogiri = (1..max).map{ Nokogiri::HTML(open_page(keyword, content)) } nokogiri.map do |n| n.search(".images_table a").map{ |x| x.attr('href').split(/=|&/)[1] } end.flatten[0, number].map(&:unescape) end |