Skip to content

Instantly share code, notes, and snippets.

@tylor
Created September 6, 2011 21:29
Show Gist options
  • Save tylor/1199029 to your computer and use it in GitHub Desktop.
Save tylor/1199029 to your computer and use it in GitHub Desktop.
Log Translink bus data
/**
* 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