【问题标题】:How to solve operator error on Twitter search API 2.0如何解决 Twitter 搜索 API 2.0 上的操作员错误
【发布时间】:2021-05-29 03:33:21
【问题描述】:

我已阅读用于实现高级搜索 API 版本的 Twitter 搜索 API 2.0 新版本的完整文档。目前,我正在使用 python 从 Twitter 获取推文,并且正在使用 searchtweets 库来实现它。我已经在我的开发者门户中设置了免费的高级搜索 API 层。

问题 - 当我尝试获取基于 $CASHTAGS (如 $AMZN)的推文时,它说不允许使用 $CASHTAGS,但根据文档,我可以使用 $CASHTAGS 过滤。

我的代码 -

account_type = 'premium'
endpoint = 'https://api.twitter.com/1.1/tweets/search/fullarchive/development.json'

from searchtweets import gen_rule_payload 
from searchtweets import ResultStream

query = '($AMZN)'
rule = gen_rule_payload(query, results_per_call=100, from_date="2021-02-01", to_date="2021-02-10")

rs = ResultStream(rule_payload=rule,
                  max_results=3000,
                  **premium_search_args)

for tweet in rs.stream():
        print(tweet)

错误 -

HTTP Error code: 422: {"error":{"message":"There were errors processing your request: 
Reference to invalid operator 'cashtag'. Operator is not available in current product or product packaging.}}

【问题讨论】:

    标签: python api twitter data-science data-mining


    【解决方案1】:

    根据您的端点,您使用的是 Twitter API 1.1 endpoint='https://api.twitter.com/1.1/tweets/search/fullarchive/development.json'.

    如果您参考 Twitter API 版本 2.0,截至 2021 年 6 月 1 日,现金标签仅适用于学术研究产品轨道。

    查看链接: https://twittercommunity.com/t/reference-to-invalid-operator-cashtag-operator-is-not-available-in-current-product-or-product-packaging/141990/7

    【讨论】:

    • 谢谢。我希望他们也能在主文档中更新这些细节。
    猜你喜欢
    • 2012-10-28
    • 2019-09-21
    • 2020-07-09
    • 2011-04-29
    • 1970-01-01
    • 2016-07-26
    • 2018-09-13
    • 1970-01-01
    • 2015-11-15
    相关资源
    最近更新 更多