使用 Tweepy 访问 Twitter 的高级 API [英] Using Tweepy to Access Twitter's Premium API

查看:46
本文介绍了使用 Tweepy 访问 Twitter 的高级 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问 Twitter 的档案,而不受速率限制或查询数量的限制.我不介意为此付费,所以我的计划是注册 高级套餐 在 Twitter 的 API 平台上.由于我熟悉 Tweepy,我曾希望能够以我通常的方式访问 API.

I want to access Twitter's archive without being restricted by rate limits or number of queries. I don't mind paying for this, so my plan was to sign up for the premium package on Twitter's API platform. As I'm familiar with Tweepy, I had hoped to be able to access the API in my usual way.

但是,似乎我可以在 Python 中使用高级凭据查询 API 的唯一方法是通过 Python Twitter Search API,它基本上是高级服务的 Python 包装器.问题是高级访问的身份验证协议与限速免费访问的身份验证协议不同.这是最烦人的,因为支持 Python Twitter Search API 的 searchtweets 库看起来相当原始,我几乎看不懂这些文档.

However, it seems that the only way I can query the API with premium credentials in Python is through the Python Twitter Search API, which is basically a python wrapper for the premium service. The issue is that the authentication protocols for premium access are not the same as for the rate-limited free access. This is most annoying, as the searchtweets library that supports the Python Twitter Search API seems fairly primitive, and I can make practically no sense of the docs.

有谁知道是否可以使用 Tweepy 访问 Twitter 的高级层?更好的工具只适用于免费层,这有点奇怪.

Does anyone know whether it is possible to use Tweepy to access premium tier for Twitter? It's kinda weird that the better tools only work on the free tier.

推荐答案

事实并非如此.您可以对标准搜索和高级搜索使用相同的凭据(假设您已获得 Twitter 授权).

That is not true. You can use the same credentials (assuming you get authorized by Twitter) for both the Standard Search and the Premium Search.

TwitterAPI python 包装器支持两者——https://github.com/geduldig/TwitterAPI

The TwitterAPI python wrapper supports both -- https://github.com/geduldig/TwitterAPI

from TwitterAPI import TwitterAPI
api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret)
r = api.request('tweets/search/fullarchive/:YOUR_LABEL',
                {'query':YOUR_SEARCH_TERMS})
for item in r:
    print(item)

这篇关于使用 Tweepy 访问 Twitter 的高级 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆