我安装了 twitter wrapper for python 安装并运行它但得到这个错误
Traceback (most recent call last):
File "/home/siddhartha/workspace/trouveunappart/src/test.py", line 35, in <module>
sid()
File "/home/siddhartha/workspace/trouveunappart/src/test.py", line 12, in sid
t = Twitter(
NameError: global name 'Twitter' is not defined
代码是:
from twitter import *
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
OAUTH_TOKEN = ''
OAUTH_SECRET = ''
t = Twitter(
auth=OAuth(OAUTH_TOKEN, OAUTH_SECRET,
CONSUMER_KEY, CONSUMER_SECRET)
)
since_ID = -1
max_ID = 0
while(since_ID != max_ID):
search = t.search.tweets(q = k, count = 100, since_id = max_ID)
print len(search['statuses'])
if len(search['statuses']) == 0:
print 'end'
break
since_ID = search['search_metadata']['since_id_str']
max_ID = search['search_metadata']['max_id_str']