0
我安裝的是Twitter的包裝爲Python安裝並運行它,但得到這個錯誤NameError:全球名「推特」沒有定義
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']
_我們在談論哪一個twitter圖書館? – kirelagin
@kirelagin http://mike.verdone.ca/twitter/#development – codious
這是否值得-1?我認爲它很難弄清楚爲什麼這不起作用 – codious