Created
December 26, 2018 21:06
-
-
Save nhfruchter/8ab19cce240f13cb227f1ffe57a56203 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def fetchPredictions(): | |
apikey = "" | |
filter_route = "Green-B,Green-C,Green-D,Green-E" | |
include = "vehicle,trip" | |
p = {"filter[route]": filter_route, "include": include} | |
result = requests.get("https://api-v3.mbta.com/predictions", params=p).json() | |
return result | |
def findNew(result): | |
SERIES = "39" | |
out = [] | |
for v in result['included']: | |
if v['attributes'].get('label'): | |
ids = v['attributes'].get('label').split("-") | |
if any(id.startswith(SERIES) for id in ids): | |
out.append(v) | |
return out | |
print(findNew(fetchPredicions)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment