Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Tweepy中获取tweet ID_Python_Tweepy_Status - Fatal编程技术网

Python 如何在Tweepy中获取tweet 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

我想搜索一个关键词,得到70条推文,然后列出所有推文的ID。我不知道怎么做,请帮忙

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'])