Tweepy 代码无法收集推文 -- Python

Tweepy code does not work to collect Tweets -- Python

我正在尝试在 python 中使用 tweepy 收集推文。但是,游标功能似乎不起作用。该错误表明 'API' 对象没有属性 'search' .

代码:

from config import *
import tweepy
import datetime

access_token="ACCESS TOKEN HERE"
access_token_secret="ACCESS TOKEN SECRET HERE"
consumer_key="CONSUMER KEY HERE"
consumer_secret="CONSUMER KEY SECRET HERE"
auth= tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)

api = tweepy.API(auth,wait_on_rate_limit=True)

today = datetime.date.today()
yesterday= today - datetime.timedelta(days=1)
today, yesterday

tweets_list = tweepy.Cursor(tweepy.api.search, q="#Covid-19 since:" + str(yesterday)+ " 
until:" + str(today),tweet_mode='extended', lang='it').items()

如果您使用的是 Tweepy v4,这已更改为 API.search_tweets() https://docs.tweepy.org/en/latest/changelog.html#version-4-0-0