def get_hydrated(writer, tweet_ids):
"""Get hydrated Tweet-objects from a list of Tweet ids."""
LOGGER.info("get_hydrated() starting")
# initialize config and Twitter API
config = read_config()
api = get_oauth_api(config) # OAuth gives more capacity for the statuses/lookup API
# process Tweet ids, storing returned Tweets in JSON format
num_tweets = 0
for chunk in gen_chunks(tweet_ids, size=LOOKUP_STATUSES_PER_REQUEST):
try:
num_tweets = write_objs(writer, api.statuses_lookup, {"id_": chunk[0]})
except TweepError as err:
log_tweep_error(LOGGER, err)
LOGGER.info("downloaded %d Tweet(s)", num_tweets)
# finished
LOGGER.info("get_hydrated() finished")
评论列表
文章目录