我正在尝试使用tweepy库从twitter收集一些数据来进行一些情绪分析。
以下是我正在运行的脚本示例:
import tweepy
import pandas as pd
import numpy as np
auth = tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
api = tweepy.API(auth, parser = tweepy.parsers.JSONParser())
# Set search query
searchquery = '"atiku" -filter:retweets'
data = api.search(q = searchquery, count = 100, lang = 'en', result_type = 'mixed')
data_all = list(data.values())[0]
#(data.values())[1])
while (len(data_all) <= 20000):
time.sleep(5)
last = data_all[1]['id']
data = api.search(q = searchquery, count = 100, lang = 'en', result_type = 'mixed', max_id = last)
data_all += list(data.values())[1][1:]
print(data_all)
我在我的代码中遇到了一个障碍,就像我运行它时出现了这个错误:
TypeError: unhashable type: 'slice'
我会很感激你的任何指示