【发布时间】: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
【问题讨论】: