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({
host:
'www.nseindia.com',<http://www.nseindia.com/live_market/dynaContent/live_watch/stock_watch/juniorNiftyStockWatch.json>
path: '
/live_market/dynaContent/live_watch/stock_watch/juniorNiftyStockWatch.json<http://www.nseindia.com/live_market/dynaContent/live_watch/stock_watch/juniorNiftyStockWatch.json>
',
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);
}
});
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en