我想使用PRAW为我的reddit帖子设置风格,有人可以建议解决方案吗?

时间:2018-10-25 18:53:18

标签: python reddit praw

我正在学习PRAW API,以创建自动在subreddit上发布内容并对其进行脚本编写的机器人,但需要特别注意。我试图用这条线来设置风格:

reddit.subreddit(sub_reddit).flair.set('bboe', 'bahissiteleri flair')

from praw API documentation

有人可以建议我解决方案吗?

import praw
sub_reddit = 'bahissiteleri' #this is the subreddit you are posting to.

post_title = 'Check' # this is the post title
post_body = "check" # this is the post text/body


reddit = praw.Reddit(
    client_id='id',
    client_secret='secret',
    username='username',
    password='password',
    user_agent="Agent to post")

def authenticate(reddit):
    print(reddit.user.me())

def self_post():
    # try:
    # post = reddit.subreddit(sub_reddit).submit(title=post_title, selftext=post_body)
    # reddit.subreddit(sub_reddit).flair.set('bboe', '')
    sub=reddit.subreddit(sub_reddit)
    post = sub.submit(title=post_title, selftext=post_body)

    reddit.subreddit(sub_reddit).flair.set('bboe', 'bahissiteleri flair')
    print("DONE")


if __name__ == '__main__':
    authenticate(reddit)
    self_post()

1 个答案:

答案 0 :(得分:0)

使用ca-app-pub-9611919736642270/3440171834 不会更改您的flair.set变量中的任何内容。我想这就是你要的:

post