caltrain

package module
v0.0.0-...-ffbc5aa Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2016 License: MIT Imports: 5 Imported by: 0

README

caltrain

caltrain provides realtime train timings for various train stations in both directions. It does so by scraping the Caltrain mobile page.

Note, Caltrain alerts are not reflected in train timings.

Please don't abuse this api.

See https://godoc.org/github.com/sent-hil/caltrain-realtime for more api.

Install

go get github.com/sent-hil/caltrain-realtime

Usage

package main

import (
  "github.com/sent-hil/caltrain-realtime"
)

func main() {
  timings, err := caltrain.GetRealTimings(caltrain.SanFrancisco, caltrain.SouthBound)
}

Documentation

Overview

caltrain provides realtime train timings for various train stations in both directions. It does so by scraping the Caltrain mobile page.

Note, Caltrain alerts are not reflected in train timings.

Please don't abuse this api.

Example:

package main

import (
  "github.com/sent-hil/caltrain-realtime"
)

func main() {
  timings, err := caltrain.GetRealTimings(caltrain.SanFrancisco, caltrain.SouthBound)
}

Index

Constants

View Source
const (
	// direction of trains
	SouthBound Direction = 0
	NorthBound Direction = 1

	// list of train strations as of June 1, 2016
	SanFrancisco          Station = "sanfrancisco"
	TwentySecondStreet    Station = "22ndstreet"
	Bayshore              Station = "bayshore"
	SouthSanFrancisco     Station = "southsanfrancisco"
	SanBruno              Station = "sanbruno"
	MillbraeTransitCenter Station = "millbraetransitcenter"
	Broadway              Station = "broadway"
	Burlingame            Station = "burlingame"
	SanMateo              Station = "sanmateo"
	HaywardPark           Station = "haywardpark"
	Hillsdale             Station = "hillsdale"
	Belmont               Station = "belmont"
	SanCarlos             Station = "sancarlos"
	RedwoodCity           Station = "redwoodcity"
	Atherton              Station = "atherton"
	MenloPark             Station = "menlopark"
	PaloAlto              Station = "paloalto"
	CaliforniaAve         Station = "californiaave"
	SanAntonio            Station = "sanantonio"
	MountainView          Station = "mountainview"
	Sunnyvale             Station = "sunnyvale"
	Lawrence              Station = "lawrence"
	SantaClara            Station = "santaclara"
	CollegePark           Station = "collegepark"
	SanJoseDiridon        Station = "sanjosediridon"
	Tamien                Station = "tamien"
	Capitol               Station = "capitol"
	BlossomHill           Station = "blossomhill"
	MorganHill            Station = "morganhill"
	SanMartin             Station = "sanmartin"
	Gilroy                Station = "gilroy"
)

Variables

This section is empty.

Functions

func GetRealTimings

func GetRealTimings(s Station, d Direction) (timings []time.Duration, err error)

GetRealTimings returns duration of latest trains arriving at the specified station and going the specified direction. The Caltrain realtime page provides maximum of 3 upcoming trains.

See http://www.caltrain.com/schedules/realtime/stations.html for list of stations.

See http://www.caltrain.com/schedules.html if you want scheduled timetables.

TODO: incorporate alerts which are embedded in the page.

Types

type Direction

type Direction int

type Station

type Station string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL