You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
889 B
31 lines
889 B
#!/usr/bin/env ruby
|
|
|
|
require 'open-uri'
|
|
require 'rexml/document'
|
|
|
|
COLOR_MAP = {
|
|
arrivalStatusOnTime: :green,
|
|
arrivalStatusNoInfo: :black,
|
|
arrivalStatusEarly: :red,
|
|
arrivalStatusDelayed: :blue,
|
|
arrivalStatusDepartedOnTime: :green,
|
|
arrivalStatusDepartedNoInfo: :white,
|
|
arrivalStatusDepartedEarly: :red,
|
|
arrivalStatusDepartedDelayed: :blue,
|
|
arrivalStatusCancelled: :red,
|
|
}
|
|
|
|
html = open('http://pugetsound.onebusaway.org/where/standard/stop.action?id=1_17160').read
|
|
doc = REXML::Document.new(html)
|
|
status = doc.elements['//td[contains(@class, "arrivalsStatusEntry")]']
|
|
|
|
minutes = status.elements['.//span'].text
|
|
color = COLOR_MAP.fetch(status.attributes['class'].split(/\s+/).last.to_sym, :white)
|
|
times = doc.elements.to_a('//div[@class="arrivalsTimePanel"]')
|
|
|
|
puts "#{minutes} | color=#{color}"
|
|
puts '---'
|
|
times.each do |time|
|
|
puts "#{time[0].text} - #{time[2].text}"
|
|
end
|