En Reddit, podemos publicar un comentario en cualquier envío, también podemos comentar un comentario para crear un hilo de comentarios. Un moderador de un subreddit puede marcar cualquier comentario como distinguido. Aquí veremos cómo verificar si un comentario se distingue o no usando PRAW. Usaremos el distinguished
atributo de la Comment
clase para verificar si un comentario se distingue o no.
Ejemplo 1: Considere el siguiente comentario:
El ID del comentario es: fvib7aw
# 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 ID of the comment comment_id = "fvib7aw" # instantiating the Comment class comment = reddit.comment(comment_id) # fetching the distinguished attribute distinguished = comment.distinguished if distinguished == None: print("The comment is not marked distinguished.") else: print("The comment has been marked distinguished.")
Producción :
The comment is not marked distinguished.
Ejemplo 2: Considere el siguiente comentario:
El ID del comentario es: fv9qvgo
# 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 ID of the comment comment_id = "fv9qvgo" # instantiating the Comment class comment = reddit.comment(comment_id) # fetching the distinguished attribute distinguished = comment.distinguished if distinguished == None: print("The comment is not marked distinguished.") else: print("The comment has been marked distinguished.")
Producción :
The comment is not marked distinguished.