我正在写一个脚本,用praw来获取文本数据(帖子和他们的评论),评论增加了下载的时间,这太荒谬了。在
如果我只下载文章而没有评论,它每秒大约100条,但是如果我下载评论和文章,它会下降到每秒1-2条,这只是针对顶级评论。如果我包含嵌套的注释,则1篇文章需要大约5-10分钟的时间(假设我测试的帖子是/r/raskreddit的最上面的帖子,但仍然如此)。这是我正在使用的方法,请告诉我是否有办法使这更快!在
for top_level_comment in submission.comments.list():
commentnumber += 1
comment1= long variable, not important
savepost.write(comment1)
for comment in top_level_comment.replies:
parentvar = comment.parent_id
parent = reddit.comment(parentvar[3:])
parentauthor = str(parent.author)
comment2 = again, long variable
savepost.write(comment2)
我也尝试过这种方法,认为减少带有注释请求的for语句可能会有所帮助,但是没有用
^{pr2}$
目前没有回答
相关问题 更多 >
编程相关推荐