首页 > 解决方案 > 如何从 Twitter API 完整存档搜索中排除转发和回复

问题描述

我正在尝试使用 twitter API 提取一些历史推文。我想排除转发和回复。我在这里尝试了其他建议的答案,但似乎没有任何效果。有人可以帮助我吗,我一周以来一直在努力寻找资源。以下是我的全存档搜索端点。

https://api.twitter.com/2/tweets/search/all?query=MMIW OR MMIP OR MMIWG&start_time=2015-01-01T00:00:01Z&end_time=2015-01-15T23:59:01Z&max_results=500&tweet.fields= created_at,entities,geo,id,referenced_tweets,in_reply_to_user_id,lang,possibly_sensitive,source,text,withheld&place.fields=country,full_name&user.fields=created_at,description,location,name,pinned_tweet_id,username,verified,withheld

标签: postmantweetstwitterapi-python

解决方案


好的,所以我从下面的链接中找出了 twitter 的规则和过滤运算符: https ://developer.twitter.com/en/docs/twitter-api/enterprise/rules-and-filtering/operators-by-product

我只需要在我的查询字段中添加和否定 is:retweet 操作符。例如:query=(MMIW OR MMIP OR MMIWG) -is:retweet 所以,我修改后的端点有效:

https://api.twitter.com/2/tweets/search/all?start_time=2015-01-01T00:00:01Z&end_time=2015-01-15T23:59:59Z&max_results=500&tweet.fields=created_at,entities,geo, id,lang,possibly_sensitive,source,text,withheld,in_reply_to_user_id,referenced_tweets&place.fields=country,country_code,full_name,geo,id,name&query=(MMIW OR MMIP OR MMIWG) -is:retweet&user.fields=created_at,description,location,名称,pinned_tweet_id,用户名,已验证


推荐阅读