forked from zzy96/CZ2006
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
35 lines (31 loc) · 779 Bytes
/
api.js
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
var request = require('request');
var requestOptions;
var finish = false;
var taxis = [];
var i = 0;
while (i<500 && !finish){
requestOptions = {
url: "http://datamall2.mytransport.sg/ltaodataservice/TaxiAvailability?$skip="+i,
headers: { 'AccountKey' : 'HerxddpjOWwwCWuan3jxQw==',
'UniqueUserID' : 'a8770653-13ba-463b-be96-56ad92e7cc69',
'accept' : 'application/json'},
method: 'GET',
json:{}
};
request(requestOptions, function(err, response, body){
if (err){
console.log(err);
}else if (response.statusCode === 200){
for (var i=0;i<body.value.length;i++){
taxis.push(body.value[i]);
}
console.log(taxis.length);
if (body.value.length === 0){
finish = true;
}
}else{
console.log(response.statusCode);
}
});
i+=50;
}