from TweetStore import TweetStore
from TwitterAPI.TwitterAPI import TwitterAPI
COUCH_DATABASE = 'test_db1'
TWITTER_ENDPOINT = 'statuses/filter'
TWITTER_PARAMS = {'track':'football','language':'en',}
API_KEY ="aaa"
API_SECRET = "bbb"
ACCESS_TOKEN ="ccc"
ACCESS_TOKEN_SECRET = "ddd"
storage = TweetStore(COUCH_DATABASE)
api = TwitterAPI(API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
for item in api.request(TWITTER_ENDPOINT, TWITTER_PARAMS):
if 'text' in item:
print('%s -- %s\n' % (item['user']['screen_name'], item['text']))
storage.save_tweet(item)
elif 'message' in item:
print('ERROR %s: %s\n' % (item['code'], item['message']))
使用这些代码,我们可以下载推文,但我想从特定的推文ID下载推文。我已经获得了一些推文ID,并希望下载推文文本和其他推文。