John
John

Reputation: 1594

Return all tweets of those who I am following with tweepy

I am using the wrapper to the twitter API, tweepy to access information on twitter with python 2.7.6. Using tweepy is it possible to return only the tweets from those who I am following? Or simply return a list of the of the people who I am following?

after setting up the authorization with the keys and secrets, so far I have

api = tweepy.API(auth)
tweets = api.home_timeline()
print tweets

However this returns a list of objects which look like

<tweepy.models.Status object at 0x7f02d219e910>

Upvotes: 1

Views: 913

Answers (1)

Bradley Smith
Bradley Smith

Reputation: 39

You can iterate through tweets using:

for status in tweepy.Cursor(api.user_timeline).items():

I think you will need to compile a list of users that you are following and then use the cursor() to select the ones you are interested in.

import tweepy
api = tweepy.API()
for tweet in tweepy.Cursor(api.search,
                           q="google",
                           rpp=100,
                           result_type="recent",
                           include_entities=True,
                           lang="en").items():
    print tweet.created_at, tweet.text

This for example will get tweets containing "google"

You can get a user like:

tweepy.Cursor(api.user_timeline, id="twitter")

Upvotes: 1

Related Questions