-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequesters.py
42 lines (32 loc) · 945 Bytes
/
requesters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import requests
import time
import json
# grabs some data from a station
def station_request(el_url):
# time before request was sent
before = time.time()
# sending / recieving the request
r = requests.get(el_url[2])
# time request was returned with data!
after = time.time()
# in epoch time
grab_time = (before + after) / 2
# convert data into json dict
r = r.content
r = json.loads(r)
# grab relevant data
t1 = r['ntasData'][0]['trainId']
t2 = r['ntasData'][3]['trainId']
i1 = r['ntasData'][0]['timeInt']
i2 = r['ntasData'][3]['timeInt']
# t1 = r['ntasData'][3]['trainId']
# t2 = r['ntasData'][3]['trainId']
# t1 = r['ntasData'][3]['trainId']
# t2 = r['ntasData'][3]['trainId']
station = r['stationId']
line = r['subwayLine']
print el_url[0], el_url[1]
print t1, i1
print t2, i2
print station, line, grab_time
#return out_row