Created
March 20, 2013 14:35
-
-
Save raykrueger/5205138 to your computer and use it in GitHub Desktop.
A stupid script for watching the lollapalooza ticket page :)
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
source "https://rubygems.org" | |
gem "timers" | |
gem "nokogiri" |
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
#!/usr/bin/env ruby | |
require "bundler/setup" | |
require "open-uri" | |
require "digest/sha1" | |
Bundler.require | |
@last_signature = nil | |
def check_for_changes | |
doc = Nokogiri::HTML(open("http://www.lollapalooza.com/tickets/")) | |
element = doc.css("div.ticket-choice.tc-soon").first | |
signature = Digest::SHA1.hexdigest(element.to_s) | |
if @last_signature && @last_signature != signature | |
puts "CHANGED!" | |
raise "BOOSH" | |
elsif @last_signature == nil | |
puts "first run" | |
else | |
puts "no change" | |
end | |
@last_signature = signature | |
end | |
timers = Timers.new | |
check_for_changes | |
timers.every(60) { check_for_changes } | |
loop { timers.wait } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment