title: How to properly scrape json response from reddit?
body: <p>I am attempting to save all "author" entries from the json linked below into a list however am very new to python. Can someone kindly point me in the right direction?</p>
  
  <p>the json: <a href="https://codebeautify.org/jsonviewer/cb0d0a91" rel="nofollow noreferrer">https://codebeautify.org/jsonviewer/cb0d0a91</a></p>
  
  <p>Trying to scrape a reddit thread:</p>
  
  <pre><code>import requests
  import json
  
  url ="https://www.reddit.com/r/easternshoremd/comments/72u501/going_to_be_in_the_easton_area_for_work_next_week.json"
  
  r = requests.get(url, headers={'User-agent': 'Chrome'})
  d = r.json()
  
  scrapedids = []
  
  for child in d['data']['children']:
      scrapedids.append(child['data']['author'])
  
  print (scrapedids)
  </code></pre>
  
  <p>If I switch the url from a reddit post to the subreddit then it works. For example, if I set</p>
  
  <pre><code>url = ("https://www.reddit.com/r/easternshoremd.json")
  </code></pre>
  
  <p>I believe the issue is my lack of understanding in the directory/tree (whatever it's called) of json. I've been hung up for a few hours and appreciate any assistance. </p>
  
  <p>The error: </p>
  
  <p>Traceback (most recent call last):
    File "/home/usr/PycharmProjects/untitled/delete.py", line 14, in 
      for child in d['data']['children']:
  TypeError: list indices must be integers or slices, not str</p>