Tweepy2.3不适用于旧版本PythonTwi的脚本

2024-04-20 01:08:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个Python脚本来解析twitter,它在tweepy的旧版本中运行得非常好:

consumer_key = '+++'
consumer_secret = '+++'

access_key = '+++'
access_secret = ''+++'

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)


api = tweepy.API(auth)
json_user_timeline = tweepy.binder.bind_api(
    path = '/statuses/user_timeline.json',
    payload_type = 'json', payload_list = True,
    allowed_param = ['id', 'user_id', 'screen_name', 'since_id', 'max_id', 'count', 'page', 'include_rts'])


d={} 
a=[]
h = HTMLParser.HTMLParser()
for tweet in tweepy.Cursor(json_user_timeline, api, screen_name='++user_name++', count=200, include_rts=True).items(200):
    .........
    .........

现在我已经升级到tweepy 2.3,错误如下:

allowed_param = ['id', 'user_id', 'screen_name', 'since_id', 'max_id', 'count', 'page', 'include_rts'])
File "build/bdist.linux-x86_64/egg/tweepy/binder.py", line 21, in bind_api
File "build/bdist.linux-x86_64/egg/tweepy/binder.py", line 23, in APIMethod
KeyError: 'api'

为什么?你知道吗

多谢了


Tags: keynameauthapiidjsonsecretaccess