Tweepy 搜索查询问题 [英] Tweepy search query issues

查看:15
本文介绍了Tweepy 搜索查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 Twitter 的 REST API 分析数据的程序,我希望使用具有多个关键字的查询来获得我正在寻找的结果.但是,我在使用搜索查询获取特定结果时遇到了问题.我已经按照文档使用或"搜索多个单词,但它只能在一定程度上起作用.

I'm working on a program to analyse data using Twitter's REST API, I looking to use a query with multiple keywords to get the results I'm looking for. However, I'm having issues when using a search query to get specific results. I have followed the documentation to use 'OR' search for multiple words but it's only working to a certain extent.

在这段代码中,当我使用查询时:

In this code when I use the query:

q = ('plane fly OR car drive -filter:retweets AND filter:replies')

它返回包含飞机"和飞机"字样的推文.飞"或车"&'驾驶'.但是如果我随机添加了另一个关键字过滤器,例如:

It returns tweets that either include the words 'plane' & 'fly' OR 'car' & 'drive'. But if I added another keyword filter on at random, for example:

q = ('plane fly OR car drive OR cadburys chocolate -filter:retweets AND filter:replies')

这根本不会返回任何推文.我不确定我是否误解了查询使用 OR 的方式,但我想即使没有包含cadburys Chocolate"的推文,它仍然会返回其他关键字的其他推文?

This does not return any tweets at all. I'm not sure if I'm misunderstanding the way the query works with the use of OR, but I'd imagine even if there were no tweets containing 'cadburys chocolate', it would still return the other tweets for the other keywords?

有谁知道我哪里出错了?如果查询可以这样构造?或者,如果没有,有没有一种方法可以在一个查询中搜索多个关键字/短语?

Does anyone know where I am going wrong? If the query can be structured this way? Or if not, is there a way I can search for multiple keywords/phrases in one query?

感谢您的时间,感谢您的帮助.

Thanks for you time, any help is appreciated.

推荐答案

https://unionmetrics.com/resources/how-to-use-advanced-twitter-search-queries/根据这个链接:您还可以将多个关键字链接在一起以创建更复杂的查询.OR 运算符将附加到它之前的单词上,非常类似于代数中的运算顺序.例如,以下查询将查找提及社交媒体指标或社交媒体分析的推文,因为 OR 链接到指标和分析术语

https://unionmetrics.com/resources/how-to-use-advanced-twitter-search-queries/ According to this link: You can also chain together multiple keywords to create a more complex query. The OR operator will attach to the word that immediately precedes it, very much like order of operations in algebra. For example, the following query will find tweets that mention social media metrics or social media analytics, because the OR links to the metrics and analytics terms

q="social media metrics OR analytics" 将返回包含单词的结果社交媒体指标或社交媒体分析

q="social media metrics OR analytics" would return results containing the words social media metrics or social media analytics

您没有看错,只是一直不清楚如何搜索长度超过 1 个单词的术语.

You're not wrong, but it was just never clear on how to search for terms longer than 1 word.

这篇关于Tweepy 搜索查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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