En Reddit, podemos publicar un comentario en cualquier envío, también podemos comentar un comentario para crear un hilo de comentarios. Un comentario se puede editar más tarde después de publicarlo. Aquí veremos cómo verificar si un comentario ha sido editado o no usando PRAW. Usaremos el edited
atributo de la Comment
clase para verificar si un comentario ha sido editado 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 edited attribute edited = comment.edited if edited == True: print("The comment has been edited.") elif edited == False: print("The comment has not been edited.")
Producción :
The comment has not been edited.
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 edited attribute edited = comment.edited if edited == True: print("The comment has been edited.") elif edited == False: print("The comment has not been edited.")
Producción :
The comment has not been edited.