Skip to content

Instantly share code, notes, and snippets.

@MarkPochert
Created February 11, 2013 21:43
Show Gist options
  • Save MarkPochert/4757883 to your computer and use it in GitHub Desktop.
Save MarkPochert/4757883 to your computer and use it in GitHub Desktop.
function fetch_orders(exchange_url,redis_key){
u = url.parse(exchange_url)
console.log("LOS - " + redis_key);
var options = {
host: u.hostname,
path: u.path,
agent: false,
headers: {
'User-Agent': 'Mozilla/4.0 (compatible; MtGox node.js client)',
'Content-type': 'application/x-www-form-urlencoded'
}
};
http.get(options, function(res) {
console.log("Got response: " + res.statusCode);
res.setEncoding('utf8');
var buffer = '';
res.on("data", function(chunk) {
buffer.push(chunk);
});
res.on('end', function(){
client.set(redis_key, buffer.toString());
//client.expire(redis_key,15);
});
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
setTimeout((function() { fetch_orders(exchange_url,redis_key); }), 10000);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment