2017-04-16 12 views
1

私はPython APIを使用しており、特定のクエリを使わずにTwitterから最も人気のあるつぶやきを取得したいと考えています。私はすべての人気のつぶやきだけでなく、特定の検索用語に関連するものです。最も人気のあるつぶやきをクエリなしで取得するには?

api = twitter_connect() 

for tweet in tweepy.Cursor(api.search, q='query',result_type='popular').items(5): 
    print(tweet.text) 

残念ながら、Twitter APIでは、queryパラメータが必要です。検索クエリから独立した最も人気のあるつぶやきを取得するにはどうすればよいですか?

+0

あなたの質問は意味をなさない。 *どのツイートが最も人気があるのか​​を調べるクエリがなくても、どのツイートが最も人気があるのか​​を知るにはどうすればいいですか?*は問題ではありません。 –

答えて

1

Twitter API trends/placeを試してみてください。

trends/place (この投稿の時点で、一例)特定WOEID (Yahoo! Where On Earth ID)

trends1 = api.trends_place(1) # Global information is available by using 1 as the WOEID . 
data = trends1[0] 
trends = data['trends'] 

for trend in trends[0:5]: # Get only the first 5 popular trending tweets 
    print trend 

出力するためのトップ50トレンドトピックを返す:

{u'url': u'http://twitter.com/search?q=%23GagaCoachella', u'query': u'%23GagaCoachella', u'tweet_volume': 83882, u'name': u'#GagaCoachella', u'promoted_content': None} 
{u'url': u'http://twitter.com/search?q=%23FallonStylesSNL', u'query': u'%23FallonStylesSNL', u'tweet_volume': 538109, u'name': u'#FallonStylesSNL', u'promoted_content': None} 
{u'url': u'http://twitter.com/search?q=%22Happy+Easter%22', u'query': u'%22Happy+Easter%22', u'tweet_volume': 485731, u'name': u'Happy Easter', u'promoted_content': None} 
{u'url': u'http://twitter.com/search?q=%23Bug%C3%BCnHay%C4%B1r%C3%87%C4%B1kacak', u'query': u'%23Bug%C3%BCnHay%C4%B1r%C3%87%C4%B1kacak', u'tweet_volume': 25544, u'name': u'#Bug\xfcnHay\u0131r\xc7\u0131kacak', u'promoted_content': None} 
{u'url': u'http://twitter.com/search?q=%23JavierDuarte', u'query': u'%23JavierDuarte', u'tweet_volume': 67939, u'name': u'#JavierDuarte', u'promoted_content': None} 

ドキュメントからクエリをカスタマイズするその他のオプションについては、documentationを参照してください。

関連する問題