En Reddit, un redditor es el término dado a un usuario. Aquí veremos cómo obtener la hora exacta en que un redditor creó su cuenta. Usaremos el created_utc
atributo de la Redditor
clase para obtener la hora de Unix cuando el redditor creó su cuenta.
Ejemplo 1: Considere el siguiente redditor:
El nombre de usuario del redditor es: spez.
# importing the module import praw from datetime import datetime # 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 Unix time of creation unix_time = redditor.created_utc print("The " + redditor_name + " account was created on Unix time : " + str(unix_time)) # converting the Unix time print("The " + redditor_name + " account was created on : " + str(datetime.fromtimestamp(unix_time)))
Producción :
The spez account was created on Unix time : 1118030400.0 The spez account was created on : 2005-06-06 09:30:00
Ejemplo 2: Considere el siguiente redditor:
El nombre de usuario del redditor es: AutoModerador
# importing the module import praw from datetime import datetime # 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 Unix time of creation unix_time = redditor.created_utc print("The " + redditor_name + " account was created on Unix time : " + str(unix_time)) # converting the Unix time print("The " + redditor_name + " account was created on : " + str(datetime.fromtimestamp(unix_time)))
Producción :
The AutoModerator account was created on Unix time : 1325741068.0 The AutoModerator account was created on : 2012-01-05 10:54:28