向hvv abfahrtsmonitor发出请求并获取解析数据
hvvabfahrtsmonitor的Python项目详细描述
hvv abfahrtsmonitor
与在https://abfahrten.hvv.de/生成的链接一起使用
生成的URL需要更改为包含API/监视器(请参见示例文件内容)
用法
fromhvvabfahrtsmonitorimportHvvAbfahrtsmonitormonitor=HvvAbfahrtsmonitor(file,schema_file)monitor.get_times()#Get a dict of lists of times, in minutes, for when the buses/metros/trains are due next.
示例文件内容(json)
{"data":[{"name":"S","url":"https://abfahrten.hvv.de/api/monitors/a038583f-f72b-4e4e-ba22-9d9903ced316"},{"name":"B","url":"https://abfahrten.hvv.de/api/monitors/f76a6c23-a682-4297-aa99-f815157e2bca"}]}
模式文件示例(json模式)
{"$schema":"http://json-schema.org/draft-07/schema#","title":"Hvv Schema","definitions":{"departure":{"type":"object","properties":{"delay":{"type":"string"},"direction":{"type":"string"},"hasDelay":{"type":"boolean"},"icon":{"type":"object"},"line":{"type":"string"},"station":{"type":"string"},"time":{"type":"string"}},"required":["hasDelay","line","time"]}},"type":"object","properties":{"data":{"type":"object","properties":{"attributes":{"type":"object","properties":{"departures":{"type":"array","items":{"$ref":"#/definitions/departure"}}}}}}}}