Created
December 13, 2013 19:53
-
-
Save ericat/7950254 to your computer and use it in GitHub Desktop.
tiny scrapers series: nokogiri
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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