Search code examples
jsonreddit

Reddit data scraping with json, 'after' not making a difference in '.json?limit=<limit>&after=<id>'


I'm new to scraping, APIs in general and json, so this question may annoy some/many people, but here goes:

When I enter a url like the example 'http://www.reddit.com/r/askscience/new.json?limit=10&after=2qpfcs' in my browser, the id following 'after' doesn't seem to make a difference; posts are simply returned starting from the newest. Additionally, exchanging 'after' for 'before' makes no difference whatsoever, which seems odd to me.

All I can conclude is that I'm not using the correct format in my url for what I'm trying to do. Could anyone tell me what to enter so that I will receive x number of posts starting from a given id?


Solution

  • The id shouldn't be appended to after=, but rather the value of attribute data-fullname="<xx>", listed as name in the returned json, which will usually have two characters, an underscore, then the post's id, e.g. t3_2qpfcs.