简体   繁体   English

如何在tweepy的一条推文中搜索多个单词?

[英]How to search more than one word in a single tweet at the tweepy?

I need to search for tweets that have a set of words, but when I enter the search terms, they are searched independently. 我需要搜索包含一组单词的推文,但是当我输入搜索词时,它们是独立搜索的。

For example, if I use this following parameter to search for "WORDS = ['amazon fire', 'rainforest fires']", the results are tweets containing 'amazon' or 'fire' or 'rainforest' or 'fires', not a tweet featuring 'amazon fire' and others containing 'rainforest fires'. 例如,如果我使用以下参数搜索“ WORDS = ['amazon fire','rainforest fires']”,则结果为包含“ amazon”或“ fire”或“ rainforest”或“ fires”的推文包含“亚马逊大火”和其他包含“雨林大火”的推文。

WORDS = ['amazon fire', 'amazon Forest', 'amazon rainforest fires', 'amazon blazes', 'amazon burning']

I hope the result is a tweet that contains more than one independently searched word. 我希望结果是一条推文,其中包含多个独立搜索的词。 Like a tweet that is 'The Amazon in Brazil is on fire' and not a tweet 'I set my keyboard on fire' 就像一条推文“巴西的亚马逊着火了”,而不是一条推文“我把键盘放火了”

The full code can be found here: https://pastebin.com/zSZfhA02 完整的代码可以在这里找到: https : //pastebin.com/zSZfhA02

You code is right and is working as espected. 您的代码正确无误,并且按预期工作。

But the WORDS you are looking for are in the quoted_status or the retweeted_status , if exists in the data. 但是,如果要查找的quoted_status在数据中存在,则在quoted_statusretweeted_status中。

You can read for further informations here : 您可以在这里阅读更多信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM