title: Access the next page of list results in Reddit API
body: <p>I'm trying to play around with the API of Reddit, and I understand most of it, but I can't seem to figure out how to access the next page of results (since each page is 25 entries). </p>
  
  <p>Here is the code I'm using:</p>
  
  <pre><code>import requests
  import json
  
  r = requests.get(r'https://www.reddit.com/r/Petscop/top.json?sort=top&amp;show=all&amp;t=all')
  
  listing = r.json()
  
  after = listing['data']['after']
  
  data = listing['data']['children']
  
  for entry in data:
      post = entry['data']
      print post['score']
  
  query = 'https://www.reddit.com/r/Petscop/top.json?after='+after
  r = requests.get(query)
  
  listing = r.json()
  
  data = listing['data']['children']
  
  for entry in data:
      post = entry['data']
      print post['score']
  </code></pre>
  
  <p>So I extract the after ID as <code>after</code>, and pass it into the next request. However, after the first 25 entries (the first page) the code returns just an empty list (<code>[]</code>). I tried changing the second query as:</p>
  
  <pre><code>r = requests.get(r'https://www.reddit.com/r/Petscop/top.json?after='+after)
  </code></pre>
  
  <p>And the result is the same. I also tried replacing "after" with "before", but the result was again the same. </p>
  
  <p>Is there a better way to get the next page of results?</p>
  
  <p>Also, what the heck is the <code>r</code> in the get argument? I copied it from an example, but I have no idea what it actually means. I ask because I don't know if it is necessary to access the next page, and if it is necessary, I don't know how to modify the query dynamically by adding <code>after</code> to it. </p>