【问题标题】:How to search more than one word in a single tweet at the tweepy?如何在 tweepy 的一条推文中搜索多个单词?
【发布时间】:2020-01-12 17:17:45
【问题描述】:

我需要搜索包含一组词的推文,但是当我输入搜索词时,它们是独立搜索的。

例如,如果我使用以下参数搜索“WORDS = ['amazon fire', 'rainforest fires']”,结果是包含“amazon”或“fire”或“rainforest”或“fires”的推文',而不是包含“亚马逊火灾”和其他包含“雨林火灾”的推文。

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

我希望结果是一条包含多个独立搜索词的推文。就像一条推文是“巴西的亚马逊着火了”,而不是一条推文“我的键盘着火了”

完整代码可以在这里找到:https://pastebin.com/zSZfhA02

【问题讨论】:

  • 你能发布你的结果吗?
  • 您是否考虑过只使用 twitter API,它将空格 (' ') 解释为 and,将逗号 ',' 解释为 ors。
  • 这篇文章让您看起来可以在查询中使用ANDORstackoverflow.com/questions/37737264/…
  • { "_id" : ObjectId("5d6c2c88f67543440c4a0af7"), "created_at" : "Sun Sep 01 20:42:39 +0000 2019", "id" : NumberLong(1168262919689310208), "text" :“RT _RMills:亚马逊不是地球的肺\n”,“用户”:{“id”:NumberLong(955684716824420352),“名称”:“Ann Zamora”,“screen_name”:“annzamoraa”,“位置”: "Texas, USA", "url" : null }, "lang" : "en", "extended_tweet" : "RT _RMills: The Amazon Is Not Earth's Lungs\n" }
  • @MasonCaiby 我会读这篇文章

标签: python search twitter tweepy


【解决方案1】:

您的代码是正确的,并且按预期工作。

但您要查找的 WORDS 位于 quoted_statusretweeted_status(如果数据中存在)。

你可以在这里阅读更多信息:

【讨论】:

  • 如果我想获得原始推文,我应该阅读什么来改变它?我无法比当前的代码更好。
猜你喜欢
  • 1970-01-01
  • 2017-12-26
  • 2015-08-20
  • 1970-01-01
  • 1970-01-01
  • 2017-03-30
  • 2017-02-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多