fork download
  1. # your code goes hereimport praw
  2. from datetime import datetime, timezone
  3.  
  4. client_id = 'xxx'
  5. client_secret = 'xxx'
  6. username = 'xxx'
  7. password = 'xxx'
  8.  
  9. reddit = praw.Reddit(client_id=client_id,
  10. client_secret=client_secret,
  11. username=username,
  12. password=password,
  13. user_agent='xxx')
  14.  
  15. subreddit_name = 'xxx'
  16. subreddit = reddit.subreddit(subreddit_name)
  17.  
  18. post_count = 0
  19.  
  20. last_post_name = None
  21.  
  22. for _ in range(3):
  23.  
  24. posts = subreddit.new(limit=None, params={'after': last_post_name})
  25.  
  26. for submission in posts:
  27. post_date = datetime.fromtimestamp(submission.created_utc, tz=timezone.utc)
  28. print(f"Post ID: {submission.id}, Date: {post_date}")
  29. post_count += 1
  30. last_post_name = submission.fullname
  31.  
  32. print(f"Amount of Posts: {post_count}")
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/py_compile.py", line 117, in compile
    raise py_exc
py_compile.PyCompileError:   File "prog.py", line 28
    print(f"Post ID: {submission.id}, Date: {post_date}")
                                                       ^
SyntaxError: invalid syntax

stdout
Standard output is empty