Python PRAW – 获取 redditor 的链接业力
在 Reddit 中,redditor 是给予用户的术语。 Reddit 业力是您在 Reddit 上发布和评论所获得的分数。在这里,我们将看到如何获取通过 redditor 在 Reddit 上发布提交获得的业力。我们将使用Redditor
类的link_karma
属性来获取链接业力。
示例 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("The link karma of " + redditor_name + " is : " +
str(redditor.link_karma))
输出 :
The link karma of spez is : 130856
示例 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("The link karma of " + redditor_name + " is : " +
str(redditor.link_karma))
输出 :
The link karma of AutoModerator is : 10815