I am trying to get all the links in subreddit using the API, but it returns only one url. Here is the code I have:
var request = require('request'); webpage = 'http://www.reddit.com/r/AmazonUnder5/top.json?limit=100'; //login request.post('http://www.reddit.com/api/login',{form:{api_type:'json', passwd:'password', rem:true, user:'username'}}); //get urls request({uri : webpage, json:true, headers:{useragent: 'mybot v. 0.0.1'}}, function(error, response, body) { if(!error && response.statusCode == 200) { for(var key in body.data.children) { var url = body.data.children[key].data.url; console.log(url); } } });
When I visit the json link in my browser, it returns all 100 messages.
source share