Skip to content

Instantly share code, notes, and snippets.

@bswinnerton
Created December 18, 2012 03:37
Show Gist options
  • Save bswinnerton/4324773 to your computer and use it in GitHub Desktop.
Save bswinnerton/4324773 to your computer and use it in GitHub Desktop.
Reddit Image Scraper
require 'faraday'
require 'nokogiri'
url = "http://reddit.com/r/pics"
request = Faraday.get(url)
doc = Nokogiri::HTML.parse(request.body)
doc.css("img").map do |x|
puts "<img src=\"" + x.attributes["src"] + "\" width=\"" + x.attributes["width"].to_s + "\" height=\"" + x.attributes["height"].to_s + "\">"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment