Exemplo n.º 1
0
func fetchLiveDepartures(from string, to string) (*ldb.GetDepartureBoardResponse, error) {
	req, err := ldb.NewGetDepartureBoardRequest(5, from, to)
	if err != nil {
		return nil, err
	}
	res, err := fetch(req)
	if err != nil {
		return nil, err
	}
	data, err := ldb.ParseGetDepartureBoardResponse(res)
	if err != nil {
		return nil, err
	}
	return data, nil
}
Exemplo n.º 2
0
Arquivo: fetch.go Projeto: oesmith/agr
func main() {
	flag.Parse()
	req, err := ldb.NewGetDepartureBoardRequest(*rows, *from, *to)
	if err != nil {
		log.Fatal(err)
	}
	c := &http.Client{}
	res, err := c.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	data, err := ldb.ParseGetDepartureBoardResponse(res)
	if err != nil {
		log.Fatal(err)
	}
	r := data.GetStationBoardResult
	log.Printf("result: %+v", r)
	for _, s := range r.TrainServices.Service {
		log.Printf("origin: %+v", s.Origin.Location)
		log.Printf("destination: %+v", s.Destination.Location)
		log.Printf("service: %+v", s)
	}
}