Python 如何在Tweepy中获取tweet ID
我想搜索一个关键词,得到70条推文,然后列出所有推文的ID。我不知道怎么做,请帮忙Python 如何在Tweepy中获取tweet ID,python,tweepy,status,Python,Tweepy,Status,我想搜索一个关键词,得到70条推文,然后列出所有推文的ID。我不知道怎么做,请帮忙 import tweepy import time auth = tweepy.OAuthHandler('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','xxxxxxxxxxxxxxxxxxxxxxxxxx') auth.set_access_token('xxxxxxxxxxxxxxxxxxxxxxx','xxxxxxxxxxxxxxxxxxxxxxxxxxx') api = twee
import tweepy
import time
auth = tweepy.OAuthHandler('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx','xxxxxxxxxxxxxxxxxxxxxxxxxx')
auth.set_access_token('xxxxxxxxxxxxxxxxxxxxxxx','xxxxxxxxxxxxxxxxxxxxxxxxxxx')
api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
user = api.me()
import time
time_limit_sec = 600
start_time = time.time()
for tweet in tweepy.Cursor(api.search, q="books", result_type="recent").items(70):
status = api.get_status(id)
id = status.id
print("The ID of the status is :" + str(id))
break
tweet id位于_json['id']下。不要使用break,当您设置项目时,它将限制为70(70)
for tweet in tweepy.Cursor(api.search, q="books", result_type="recent").items(70):
print("The tweet id is:", tweet._json['id'])