【问题标题】:PRAW: Get limited amount of new comments from submissionPRAW:从提交中获得有限数量的新评论
【发布时间】:2017-02-28 11:44:48
【问题描述】:

我正在尝试编写代码来存储 variable 数量的 new cmets 从提交的帖子到文件。我当前形式的代码可以工作,但它总是返回相同的 cmets。换句话说,我可以每隔几个小时运行它,而新的 cmets 将不会显示。我尝试关注this 页面和其他各种网站,但找不到任何相关信息。

非常感谢任何帮助!

post = reddit.submission(url=link)

fileName = "out/" + platform.lower() + ".txt"
file = open(fileName, 'w+')

for top_level_comment in post.comments:
    # Get comment
    try:
        body = top_level_comment.body   
        # Parse each line of comment
        for line in body.splitlines():
            file.write(line + "\n") 
    except:
        continue

【问题讨论】:

    标签: python praw reddit


    【解决方案1】:

    答案很简单:

    post.comment_sort = 'new'
    

    这不是在原始的 PRAW 评论文档中,而是找到了 here

    【讨论】:

      猜你喜欢
      • 2014-01-16
      • 2017-10-24
      • 1970-01-01
      • 2014-09-05
      • 2012-12-29
      • 1970-01-01
      • 1970-01-01
      • 2012-01-20
      • 1970-01-01
      相关资源
      最近更新 更多