Python PRAW - 检查 redditor 是否有 Reddit 高级版
在 Reddit 中,redditor 是给予用户的术语。 Reddit 允许 redditor 付费访问高级访问权限。在这里,我们将看到如何检查 redditor 是否具有高级访问权限。我们将使用Redditor
类的is_gold
属性来检查 redditor 是否具有高级访问权限。
示例 1:考虑以下 redditor:
redditor 的用户名是:spez。
# importing the module
import praw
# initialize with appropriate values
client_id = ""
client_secret = ""
username = ""
password = ""
user_agent = ""
# creating an authorized reddit instance
reddit = praw.Reddit(client_id = client_id,
client_secret = client_secret,
username = username,
password = password,
user_agent = user_agent)
# the name of the redditor
redditor_name = "spez"
# instantiating the Redditor class
redditor = reddit.redditor(redditor_name)
print("Does " + redditor_name + " has an active Reddit Premium status? : " +
str(redditor.is_gold))
输出 :
Does spez has an active Reddit Premium status? : True
示例 2:考虑以下 redditor:
redditor 的用户名是:AutoModerator
# importing the module
import praw
# initialize with appropriate values
client_id = ""
client_secret = ""
username = ""
password = ""
user_agent = ""
# creating an authorized reddit instance
reddit = praw.Reddit(client_id = client_id,
client_secret = client_secret,
username = username,
password = password,
user_agent = user_agent)
# the name of the redditor
redditor_name = "AutoModerator"
# instantiating the Redditor class
redditor = reddit.redditor(redditor_name)
print("Does " + redditor_name + " has an active Reddit Premium status? : " +
str(redditor.is_gold))
输出 :
Does AutoModerator has an active Reddit Premium status? : True