如何用虾浏览 Reddit 中的帖子 [英] How to look through post in Reddit with praw

查看:49
本文介绍了如何用虾浏览 Reddit 中的帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在查看 praw 的文档,但我根本找不到用于查看所有帖子的方法.我想做的是浏览所有帖子

import ProcessingBot导入验证进口虾SETPHRASES = ["python", "bots", "jarmahent", "证明 1966 年没有全球变暖", "test"]SETPHRASE = ("这是一个机器人,忽略这个回复")用户名 = Auth.pG定义运行():r = praw.Reddit(Auth.app_ua)打印(登录")r.set_oauth_app_info(Auth.app_id, Auth.app_secret, Auth.app_uri)print("设置 Oauth 应用信息")r.refresh_access_information(Auth.app_refresh)sub = r.get_subreddit("ProcessingImages")打印(获取子Reddit")对于:#查看所有帖子,这是帖子查找器所在的位置打印(完成")返回为真:跑步()

格式有点错误,我隔了4次粘贴了还是不行.

解决方案

这在 上的示例中有介绍文档首页:

<预><代码>>>>进口虾>>>r = praw.Reddit(user_agent='my_cool_application')>>>提交 = r.get_subreddit('opensource').get_hot(limit=5)>>>[str(x) for x 在提交中]

除了get_hot,还有上升top 帖子.

I've been looking at the documentation for praw and i simply cannot find which method is for looking through all the post. What I want to do is look through all the post

import ProcessingBot
import Auth
import praw

SETPHRASES = ["python", "bots", "jarmahent", "is proves there was no Global     Warming in 1966", "test"]
SETPHRASE = ("This is a bot, ignore this reply")
USERNAME = Auth.pG

def run():
    r = praw.Reddit(Auth.app_ua)
    print("Signing In")

    r.set_oauth_app_info(Auth.app_id, Auth.app_secret, Auth.app_uri)
    print("Setting Oauth App Info")

    r.refresh_access_information(Auth.app_refresh)

    sub = r.get_subreddit("ProcessingImages")
    print("Getting SubReddit")
    for: #Look through all the post this is where the post finder will be

    print("Finished")




return r


while True:
    run()

The formatting is a little wrong, I spaced 4 times and pasted and it still didnt work.

解决方案

This is covered in the example on the documentation front page:

>>> import praw
>>> r = praw.Reddit(user_agent='my_cool_application')
>>> submissions = r.get_subreddit('opensource').get_hot(limit=5)
>>> [str(x) for x in submissions]

Aside from get_hot, there are also methods for rising and top posts.

这篇关于如何用虾浏览 Reddit 中的帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆