Python PRAW – 获取 redditor 的奖杯列表
在 Reddit 中,redditor 是给予用户的术语。 redditor 可以获得某些奖杯。在这里,我们将看到如何获取 redditor 拥有的所有奖杯。我们将使用Redditor
类的trophies()
方法来获取 redditor 拥有的所有奖杯。
奖杯()
Syntax : Redditor.trophies()
Parameter : None
Returns : List of objects of class Trophy
示例 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)
# fetching the list of tropies
trophies = redditor.trophies()
# printing the name of the trophies
for trophy in trophies:
print(trophy)
输出 :
15-Year Club
Inciteful Comment
Inciteful Link
RPAN Viewer
Not Forgotten
Sequence | Editor
Spared
Alpha Tester
Inciteful Comment
Inciteful Link
redditgifts Exchanges
Inciteful Comment
Beta Team
Inciteful Link
Inciteful Comment
Inciteful Link
Inciteful Link
Inciteful Link
Inciteful Link
Best Comment
Best Comment
Reddit Premium
reddit mold
Rally Monkey
Verified Email
ComboCommenter
示例 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)
# fetching the list of tropies
trophies = redditor.trophies()
# printing the name of the trophies
for trophy in trophies:
print(trophy)
输出 :
Eight-Year Club
Undead | Zombie
Inciteful Comment
Inciteful Comment
Well-rounded
Inciteful Comment
Well-rounded
Well-rounded
Reddit Premium