Skip to content

Instantly share code, notes, and snippets.

@pheuter
Created August 13, 2014 18:52
Show Gist options
  • Save pheuter/9b108bd425cd9d405308 to your computer and use it in GitHub Desktop.
Save pheuter/9b108bd425cd9d405308 to your computer and use it in GitHub Desktop.
Rick Ross image scraper using Nokogiri (鋸)
require 'open-uri'
require 'nokogiri'
i = 0
file = File.new "ross_image_urls.txt", "w"
50.times do
imageUrls = Nokogiri::HTML(open(URI.escape("https://www.google.com/search?q=rick+ross&biw=1301&bih=442&sei=WKvrU9nIJ43gsASAxYHQDQ&tbm=isch&ijn=2&ei=WKvrU9nIJ43gsASAxYHQDQ&start=#{i}"))).css('img').each do |image|
file.puts image['data-src']
end
i += 20
end
file.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment