Created
February 11, 2013 21:43
-
-
Save MarkPochert/4757883 to your computer and use it in GitHub Desktop.
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
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