On Saturday, July 21, 2012 2:42:28 AM UTC-4, santa wrote:
I am trying to use superagent to request data from a server. I believe the problem is setting the 'user-agent' in the request but I am having a tough time figuring out the problem. I get an access denied error.
Did you try using the core HTTP methods?
Example (untested):
var http = require('http');
http.get({
headers: {
'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/
2.0.0.13'
}
}, function(res) {
if (res.statusCode === 200) {
var body = [];
res.setEncoding('utf8');
res.on('data', function(chunk) {
body.push(chunk);
});
res.on('end', function() {
body = body.join('');
console.log(body);
});
} else {
console.log('Received non-ok response: ' + res.statusCode);
}
});