Created
February 2, 2013 04:09
-
-
Save cmhobbs/4696078 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# gem | |
require 'nokogiri' | |
# stdlib | |
require 'open-uri' | |
require 'csv' | |
puts "== SCRAPING" | |
doc = Nokogiri::HTML(open('http://hobbsc.sdf-us.org')) | |
title_text = doc.css('title').children.first.content | |
h1_text = h1 = doc.css('h1').children.first.content | |
puts "== GENERATING CSV" | |
CSV.open("/Users/christopher/tmp/file.csv", "wb") do |csv| | |
csv << ["title", "header 1"] | |
csv << [title_text, h1_text] | |
end |
This file contains hidden or 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
create any 'ol directory: | |
mkdir scraper | |
cd into that directory and make yourself a file: | |
cd scraper | |
touch scraper.rb | |
install nokogiri and pry (from anywhere): | |
gem install nokogiri pry | |
fire up pry with 'pry' and you're ready to rock. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment