import re
import csv
import json
import got
auth = tweepy.OAuthHandler("APIKEY","APISCRETKEY")
auth.set_access_token("ACCESS-TOKEN","ACESS-TOKEN-SCRETKEY")
api = tweepy.API(auth,wait_on_rate_limit=True)
'''我仅在粘贴api凭据后才获取过去7的数据'''
follow = api.followers()
#print(follow)
tag = '#lecoqsportif OR #parfum'
fileName = '_'.join(re.findall("#(\w+)",tag))
print(fileName)
with open('%s.csv' % (fileName),'w',encoding='utf-8') as file:
w = csv.writer(file)
w.writerow(['timestamp', 'tweet_text', 'username', 'all_hashtags', 'followers_count'])
for tweet in tweepy.Cursor(api.search,q = tag+'-filter:retweets',lang="en").items(10000):
w.writerow([tweet.created_at,tweet.text.replace('\n',''),tweet.user.screen_name,[e['text'] for e in tweet._json['entities']['hashtags']],tweet.user.followers_count])
'''即使我也要求10000条记录,我只获得不到1000条记录,仅相当于1周的数据。我想使用标准API(不是付费版本)获取过去12个月的数据。有没有可能,如果可以,请提供解决方案'''