User Tools

Site Tools


This little script prints the departure times of the next three U6 trains leaving Garching-Forschungszentrum.

Requires Ruby to be installed.

#!/usr/bin/env ruby
# by Joachim Wuttke, 2012

require 'net/http'
t=Net::HTTP::get( URI("http://www.mvg-live.de/ims/dfiStaticAnzeige.svc?haltestelle=Garching-Forschungszentrum&ubahn=checked") )

t=~ /<table.*\"departureTable departureView"\s*>(.*)<\/table>/ms or
    raise "return web page has no departureTable"
t = $1

out = []
while t.sub!( /<td class=\"inMinColumn\">(\d+)<\/td>/ms, "" )
    out.push( $1 )
end

puts out.join( " " )