Skip to content

Instantly share code, notes, and snippets.

@cmhobbs
Created February 2, 2013 04:09
Show Gist options
  • Save cmhobbs/4696078 to your computer and use it in GitHub Desktop.
Save cmhobbs/4696078 to your computer and use it in GitHub Desktop.
# 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
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