gpt4 book ai didi

python - 虾 6 : Get all submission of a subreddit

转载 作者:行者123 更新时间:2023-12-04 14:38:08 27 4
gpt4 key购买 nike

我正在尝试使用 PRAW 从最新到最旧迭代某个 subreddit 的提交。我以前是这样做的:

subreddit = reddit.subreddit('LandscapePhotography')
for submission in subreddit.submissions(None, time.time()):
print("Submission Title: {}".format(submission.title))

但是,当我现在尝试这样做时,出现以下错误:
AttributeError: 'Subreddit' object has no attribute 'submissions'
从查看文档我似乎无法弄清楚如何做到这一点。我能做的最好的是:
for submission in subreddit.new(limit=None):
print("Submission Title: {}".format(submission.title))

但是,这仅限于前 1000 份提交。

有没有办法对所有提交而不是前 1000 个提交执行此操作?

最佳答案

不幸的是,Reddit 从他们的 API 中删除了这个功能。

查看 PRAW changelog . 6.0.0 版本的变化之一是:

Removed



链接的帖子说 Reddit 正在为所有用户禁用 Cloudsearch:

Starting March 15, 2018 we’ll begin to gradually move API users over to the new search system. By end of March we expect to have moved everyone off and finally turn down the old system.



大虾 Subreddit.sumbissions() 使用 Cloudsearch 搜索给定时间戳之间的帖子。由于 Cloudsearch 已被删除,并且替换它的搜索不支持时间戳搜索,因此无法再使用 PRAW 或任何其他 Reddit API 客户端执行基于时间戳的搜索。这包括尝试从 subreddit 获取所有帖子。

如需更多信息,请参阅 this thread from /r/redditdev posted by the maintainer of PRAW .

备择方案

由于 Reddit 将所有列表限制为约 1000 个条目,因此目前无法使用其 API 获取 subreddit 中的所有帖子。但是,存在带有 API 的第三方数据集,例如 pushshift.io .如/u/kungming2 said on Reddit :

You can use Pushshift.io to still return data from defined time periods by using their API:

https://api.pushshift.io/reddit/submission/search/?after=1334426439&before=1339696839&sort_type=score&sort=desc&subreddit=translator

This, for example, allows you to parse submissions to r/translator between 2012-04-14 and 2012-06-2014.

关于python - 虾 6 : Get all submission of a subreddit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53988619/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com