Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve date and time from a tweepy status object?

Suppose I do

tweets = api.home_timeline()

It returns a list of 20 recent tweepy status objects that is posted on my timeline.And if I do

for tweet in tweets:
    print tweet.text

It prints 20 messages.Is it possible to retrieve the time the status was posted? What other attributes does the status object have? Help needed.

like image 768
Manoj Avatar asked Jun 03 '12 07:06

Manoj


People also ask

How do I see the time of a tweet in Tweepy?

In order to get the date and time when the status was posted, we have to do the following : Identify the status ID of the status from the GUI. Get the Status object of the status using the get_status() method with the status ID. From this object, fetch the created_at attribute present in it.

What does Tweepy return?

Returns full Tweet objects for up to 100 Tweets per request, specified by the id parameter.

Which returns a single status specified by the ID parameter?

GET statuses/show/:id Returns a single Tweet, specified by the id parameter. The Tweet's author will also be embedded within the Tweet.


1 Answers

tweet = tweets[0]
print tweet.created_at

Output will be a datetime object. E.g.:

(Pdb) tweet.created_at
datetime.datetime(2012, 6, 3, 20, 9, 24)

For all attributes, see the Twitter API docs. Tweepy docs will also interest you.

like image 156
klenwell Avatar answered Sep 28 '22 01:09

klenwell