用tweepy返回我关注的所有推文

时间:2014-09-19 20:22:56

标签: python twitter tweepy

我正在使用twitter API的包装器,使用python 2.7.6在twitter上访问信息。使用tweepy是否可以仅返回我关注的推文?或者只是返回我正在关注的人的列表?

用钥匙和秘密设置授权后,到目前为止我已经

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

然而,这会返回一个看起来像

的对象列表

<tweepy.models.Status object at 0x7f02d219e910>

1 个答案:

答案 0 :(得分:1)

您可以使用以下方式迭代推文:

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

我认为您需要编译您正在关注的用户列表,然后使用cursor()选择您感兴趣的用户。

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

例如,这将包含包含&#34; google&#34;

的推文

您可以获得以下用户:

  

tweepy.Cursor(api.user_timeline,id =&#34; twitter&#34;)