Created
September 6, 2011 21:29
-
-
Save tylor/1199029 to your computer and use it in GitHub Desktop.
Log Translink bus data
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
/** | |
* Quick and dirty snippet to log bus information provided by Translink mobile pages like: http://nb.translink.ca/StopMap/50322 | |
* Run using: $ node gather.js > log.js | |
*/ | |
var exec = require('child_process').exec; | |
var last; | |
// Grab the ASP.NET_SessionId from a browser cookie. | |
var session = '...'; | |
// Grab stop number hash from window.gsSPK from the console or from the value passed to fgVSMa() by the page. | |
var stopNo = '...'; | |
setInterval(function() { | |
var command = 'curl --cookie "ASP.NET_SessionId=' + session + ';" http://nb.translink.ca/rideapi.ashx?cp=gsab%2F' + stopNo; | |
var child = exec(command, function(error, stdout, stderr){ | |
if (stdout != last) { | |
last = stdout; | |
console.log(stdout); | |
} | |
}); | |
}, 10000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment