Python Reddit PRAW 获得最佳周奖。如何更改限制?
Python Reddit PRAW get top week. How to change limit?
我一直在为 reddit 熟悉 PRAW。我正在尝试获取本周排名前 x 的帖子,但是我在更改“top”方法的限制时遇到了问题。
文档似乎没有提到如何去做,除非我遗漏了什么。我可以通过传入字符串“week”来更改时间 period ok,但限制已被混淆。图片显示有limit参数,设置为100。
r = self.getReddit()
sub = r.subreddit('CryptoCurrency')
results = sub.top("week")
for r in results:
print(r.title)
根据您link编辑的文档:
Additional keyword arguments are passed in the initialization of
ListingGenerator.
所以我们遵循 link 并查看 ListingGenerator
的 limit
参数:
limit – The number of content entries to fetch. If limit is None, then
fetch as many entries as possible. Most of reddit’s listings contain a
maximum of 1000 items, and are returned 100 at a time. This class will
automatically issue all necessary requests (default: 100).
因此使用以下内容应该可以为您完成:
results = sub.top("week", limit=500)
我一直在为 reddit 熟悉 PRAW。我正在尝试获取本周排名前 x 的帖子,但是我在更改“top”方法的限制时遇到了问题。
文档似乎没有提到如何去做,除非我遗漏了什么。我可以通过传入字符串“week”来更改时间 period ok,但限制已被混淆。图片显示有limit参数,设置为100。
r = self.getReddit()
sub = r.subreddit('CryptoCurrency')
results = sub.top("week")
for r in results:
print(r.title)
根据您link编辑的文档:
Additional keyword arguments are passed in the initialization of ListingGenerator.
所以我们遵循 link 并查看 ListingGenerator
的 limit
参数:
limit – The number of content entries to fetch. If limit is None, then fetch as many entries as possible. Most of reddit’s listings contain a maximum of 1000 items, and are returned 100 at a time. This class will automatically issue all necessary requests (default: 100).
因此使用以下内容应该可以为您完成:
results = sub.top("week", limit=500)