使用客户端tweepy最新版本按位置过滤tweet


import tweepy as tw
client = tw.Client(bearer_token='')

我想使用从推特客户端API文档中找到的位置搜索查询来过滤推特数据。

我尝试使用bounding_box作为过滤器位置,但每次使用There were errors processing your request: no viable alternative at input '119.19,4.94,127.31,19.38'时它都会输出一个错误

query = 'crypto -is:retweet bounding_box:[119.19,4.94,127.31,19.38]'
for tweet in tw.Paginator(client.search_recent_tweets, query=query, 
tweet_fields=[ 'created_at'], max_results=100).flatten(limit=1000):
print(tweet.text, tweet.created_at)

有没有可能通过位置过滤推特数据?

用空格替换逗号:

query = 'crypto -is:retweet bounding_box:[119.19 4.94 127.31 19.38]'

正如Twitter API文档中所述:

bounding_box:[west_long south_lat east_long north_lat]

示例:bounding_box:[105.301758 39.964069-105.178505 40.09455]

规则参数包含在方括号内,用空格分隔。

最新更新