📌  相关文章
📜  Python PRAW – 阻止 redditor

📅  最后修改于: 2022-05-13 01:55:30.657000             🧑  作者: Mango

Python PRAW – 阻止 redditor

在 Reddit 中,redditor 是给予用户的术语。在这里,我们将看到如何使用 PRAW 将 redditor 阻止为经过身份验证的用户。我们将使用Redditor类的block()方法来阻止 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 redditor to be blocked
redditor_name = "spez"
  
# instantiating the Redditor class
redditor = reddit.redditor(redditor_name)
  
# blocking the redditor
redditor.block()

输出 :

示例 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 redditor to be blocked
redditor_name = "AutoModerator"
  
# instantiating the Redditor class
redditor = reddit.redditor(redditor_name)
  
# blocking the redditor
redditor.block()

输出 :