Return a users tweets with tweepy
Unfortunately, Status
model is not really well documented in the tweepy
docs.
user_timeline()
method returns a list of Status
object instances. You can explore the available properties and methods using dir()
, or look at the actual implementation.
For example, from the source code you can see that there are author
, user
and other attributes:
for status in stuff: print status.author, status.user
Or, you can print out the _json
attribute value which contains the actual response of an API call:
for status in stuff: print status._json
import tweepyimport tkinterauth = tweepy.OAuthHandler(consumer_key, consumer_secret)auth.set_access_token(access_token, access_token_secret)api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)# set parser=tweepy.parsers.JSONParser() if you want a nice printed json response.userID = "userid"user = api.get_user(userID)tweets = api.user_timeline(screen_name=userID, # 200 is the maximum allowed count count=200, include_rts = False, # Necessary to keep full_text # otherwise only the first 140 words are extracted tweet_mode = 'extended' )for info in tweets[:3]: print("ID: {}".format(info.id)) print(info.created_at) print(info.full_text) print("\n")
Credit to https://fairyonice.github.io/extract-someones-tweet-using-tweepy.html