Skip to content

Instantly share code, notes, and snippets.

@asmallteapot
Created September 11, 2011 18:25
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 asmallteapot/1209938 to your computer and use it in GitHub Desktop.
Save asmallteapot/1209938 to your computer and use it in GitHub Desktop.
Check status of the Tampa Crosstown Expressway’s reversible express lanes in Ruby. Tampa–Hillsborough Expressway Authority doesn’t offer an API, so it uses Nokogiri to scrap the official website’s status display.
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open('http://www.tampa-xway.com/'))
img_src = doc.css('img.closures').first['src']
if img_src.match /West/
puts 'Westbound'
elsif img_src.match /East/
puts 'Eastbound'
else
puts 'Closed'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment