def grab_post(subreddit, argument):
if argument == 'tophot':
post = list(subreddit.hot(limit=1))[0]
elif argument == 'topnew':
post = list(subreddit.new(limit=1))[0]
elif argument == 'randomnew':
post = secrets.choice(list(subreddit.new(limit=100)))
elif argument == 'toptop':
post = list(subreddit.top(limit=1))[0]
elif argument == 'randomtop':
post = secrets.choice(list(subreddit.top(limit=100)))
else:
post = secrets.choice(list(subreddit.hot(limit=100)))
return post
评论列表
文章目录