Hello All,

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.

For example from the shell first:

A) 
curl 
'http://www.nseindia.com/live_market/dynaContent/live_watch/stock_watch/juniorNiftyStockWatch.json'
This gives access denied

B) curl --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' 
'http://www.nseindia.com/live_market/dynaContent/live_watch/stock_watch/juniorNiftyStockWatch.json'
This works!

However when I use SuperAgent it fails. Can someone please help me fix this?
I am using the following code:

    var request = require('superagent');
    request
       
 
.get('http://www.nseindia.com/live_market/dynaContent/live_watch/stock_watch/juniorNiftyStockWatch.json')
        .set('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')
        .end(function(res){
        if (res.ok) {
         console.log(res.text);
        }
        else {
           console.log(res);
           }
        });


Thanks,
Santosh

-- 
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

Reply via email to