Skip to content

Instantly share code, notes, and snippets.

@ericat
Created December 13, 2013 19:53
Show Gist options
  • Save ericat/7950254 to your computer and use it in GitHub Desktop.
Save ericat/7950254 to your computer and use it in GitHub Desktop.
tiny scrapers series: nokogiri
require 'rubygems'
require 'nokogiri'
require 'open-uri'
url = 'http://www.greenmangaming.com/genres/action/'
doc = Nokogiri::HTML(open(url))
File.open("scrape.txt", 'w') { |f|
doc.xpath('//h2').each do |item|
f.write "#{item.text}\n"
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment