[英]Tweepy returns only 76 tweets
我正在嘗試從Twitter收集電影評論。 但是,我只有76條推文。 我試圖排除tweeterror,但這沒有幫助。 這是我的代碼:
import tweepy
import time
import cPickle as pickle
auth = tweepy.OAuthHandler(**hidden**)
auth.set_access_token(**hidden**)
api = tweepy.API(auth)
def limit_handled(cursor):
while True:
try:
yield cursor.next()
"I am awake..."
except tweepy.error:
print "going to sleep..."
time.sleep(15 * 60)
except StopIteration:
break
query = '#moviereview -filter:links'
max_tweets = 1000000
searched_tweets = [status.text for status in limit_handled(tweepy.Cursor(api.search, q=query).items(max_tweets))]
with open("twitter_reviews.pkl","wb") as f:
pickle.dump(searched_tweets,f,-1)
print len(searched_tweets)
嘗試根據您的代碼修改查詢參數,這並不是過濾掉更多結果的原因。
查詢:
'#moviereview -filter:links'
提供了78個結果(還在計數)
查詢:
'#moviereview'
提供1713個結果(計數中)
查詢:
'#moviereview Filter:links'
提供4534個結果(並進行計數)
就像@Ethan提到的+ Twitter的API文檔( https://dev.twitter.com/rest/public/search )
Twitter Search API會搜索過去7天內發布的最新Tweet樣本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.