从nextbus获取总线预测
bustracker的Python项目详细描述
总线跟踪器(nextbus)
从NextBus获取总线数据的python模块
这是一个正在进行的项目。如果您有任何请求或贡献,请创建一个ticket
安装
来自具有pip的pypi
pip install bustracker
用法示例
frombustrackerimportBusTracker# Agency list is from http://webservices.nextbus.com/service/publicXMLFeed?command=agencyListagency='ttc'bus=BusTracker(agency)# get prediction for bus stopsstops=[{'routeTag':506,'stopTag':3292}]predictions=bus.get_predictions(stops)print(predictions)
结果是一个预测字典
{"predictions":{"message":{"text":"TTC Information 416-393-4636 (INFO)","priority":"Normal"},"agencyTitle":"Toronto Transit Commission","routeTag":"506","routeTitle":"506-Carlton","direction":{"title":"West - 506 Carlton towards High Park","prediction":[{"isDeparture":"false","minutes":"2","seconds":"134","tripTag":"38216487","vehicle":"4189","block":"506_9_90","branch":"506","dirTag":"506_1_506","epochTime":"1563543576881"},...]},"stopTitle":"Gerrard St East At Jones Ave","stopTag":"3292"},"copyright":"All data copyright Toronto Transit Commission 2019."}
用于开发
测试
pytest tests/test.py