首页 > 解决方案 > 在 PRAW 中,有没有办法为多个用户获取评论流?

问题描述

有了 PRAW,我知道你可以做到

subs = reddit.subreddit("Pics+Funny")

获取 r/Pics 和 r/Funny 的流,我知道你可以做到这一点

user = reddit.redditor("spez")

获得一个用户,但是有没有办法一次获得多个用户?像这样:

users = reddit.redditor("spez+kn0wthing")?

我正在尝试阅读一大群用户的评论,我想知道这样的事情是否可行。当我尝试放在上面的内容时,它返回了 404 错误。谁能帮帮我?

标签: pythonredditpraw

解决方案


You cannot do this as you can with multireddits. However, there is a way around this with the pause_after parameter in praw comment streams.

e.g.

spezStream = reddit.redditor('spez').stream.comments(pause_after=-1)
kn0thingStream = reddit.redditor('kn0thing').stream.comments(pause_after=-1)

while True:
    for comment in spezStream:
        print(comment.body)
    for comment in kn0thingStream:
        print(comment.body)

And that should work :-)

Documentation here.


推荐阅读