[英]basic twitter search using python Tweepy library, doesn't work
Python 3.10, Tweepy version 4.10.0, trying to make basic search through tweets. Python 3.10,Tweepy 版本 4.10.0,尝试通过推文进行基本搜索。
import tweepy
consumer_key_str = 'Some consumer key'
consumer_secret_str = 'some consumer secret'
bearer_token_str = 'some bearer token string'
client = tweepy.Client(bearer_token_str)
client.consumer_key = api_key_str
client.consumer_secret = consumer_secret_str
I am trying to search it using something like:我正在尝试使用以下内容进行搜索:
res = client.search_all_tweets(query='query=sunshine')
but, I am getting an error:但是,我收到一个错误:
tweepy.errors.Forbidden: 403 Forbidden
When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.
I am unfamiliar with it all.我对这一切都不熟悉。 I have created all the keys, and have a 'project' on a twitter developer portal.
我已经创建了所有密钥,并且在 Twitter 开发者门户上有一个“项目”。 Note that when I am trying to acquire some tweets using:
请注意,当我尝试使用以下方式获取一些推文时:
tweet_ids = [1460323737035677698, 1293593516040269825, 1293595870563381249]
response = client.get_tweets(tweet_ids , tweet_fields=["created_at", "text", "geo"])
it works just fine它工作得很好
The search_all_tweets
method is accessible only if you have an Academic access.仅当您具有学术访问权限时,才能访问
search_all_tweets
方法。
You can read more about the access levels in the Twitter documentation .您可以在Twitter 文档中阅读有关访问级别的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.