2014-09-19 43 views
0

我正在使用包裝的twitter API,tweepy訪問Twitter上的信息與python 2.7.6。使用tweepy可以僅返回我所關注的人的推文嗎?或者直接返回我正在關注的人員列表?返回所有tweets我跟隨tweepy

建立與密鑰和祕密授權,到目前爲止,我

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

但是經過這將返回看起來像

<tweepy.models.Status object at 0x7f02d219e910>

+0

你看到的是狀態對象的列表。您必須訪問各個元素。像'tweets [0] .text'一樣閱讀更多:https://dev.twitter.com/rest/reference/get/statuses/home_timeline – karthikr 2014-09-19 20:27:21

回答

0

您可以遍歷鳴叫對象的列表使用:

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

我想你w生病需要編譯您所關注的用戶的列表,然後使用光標()來選擇你感興趣的人。

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 

例如,這將得到含有微博「谷歌」

你能得到這樣一個用戶:

tweepy.Cursor(api.user_timeline,ID = 「推特」)