Skip to content

Instantly share code, notes, and snippets.

@phaedryx
Last active December 19, 2015 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phaedryx/5976832 to your computer and use it in GitHub Desktop.
Save phaedryx/5976832 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'open-uri'
require 'sqlite3'
db = SQLite3::Database.new("results.db")
db.execute <<-SQL
CREATE TABLE results (
id int,
score int
);
SQL
(1..1000).each do |question_number|
begin
open("http://www.fluther.com/#{question_number}") do |page|
html = Nokogiri::HTML(page)
score = html.css(".gq-score").text.strip.to_i
db.execute("INSERT INTO results VALUES (#{question_number}, #{score})")
end
rescue
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment