我制作了这个脚本来获取带有一些标签的3200个推文, 它适用于一些hastags,然后对于其他人它只给我200条或更少的推文... 为什么????:
def getHashtag(hashtag):
data={'created_at':[],'full_text':[],'favorite_count':[],'retweet_count':[],'place':[],'coordinates':[]}
query = hashtag
max_tweets = 3200
n=0
for stat in tweepy.Cursor(api.search, q=query).items(max_tweets):
try:
n+=1
data['created_at'].append(stat.created_at)
data['full_text'].append([stat.text])
data['favorite_count'].append(stat.favorite_count)
data['retweet_count'].append(stat.retweet_count)
data['place'].append(stat.place)
data['coordinates'].append(stat.coordinates)
if n==800:
for i in range(1,300):
time.sleep(1)
n=0
print(n)
except:
break
_=pd.DataFrame(data)
save=open('%stuitsPd.pickle' % hashtag,'wb')
pickle.dump(_,save)
save.close()