ruby - 从 Twitter 搜索 API 中排除多词关键字
问题描述
我有一个要从搜索中排除的关键字列表
KEYWORDS = %w[
covid corona subway railway travel plane brazil ]
exclude = Twitter::KEYWORDS.split(",").join(" -")
这就是我的搜索查询的样子
json_response = @client.search("(javascript) -#{exclude}", lang: "en", result_type: "recent", tweet_mode: "extended", count: 100)
如何在此处传递多字关键字以排除,例如“off the hand”或“game plan”等关键字?
将它们与其他关键字一起添加不会按预期工作。
解决方案
如果有人回来寻找同样的问题,这就是我解决它的方法:
@client.search("(javascript) -#{exclude} -\"off the hand\" -\"game plan\", lang: "en", result_type: "recent", tweet_mode: "extended", count: 100)
因此,基本上通过使用转义字符,我可以将多字关键字作为精确字符串传递。
推荐阅读
- javascript - 您可以在没有 JavaScript 的情况下使用 Google reCAPTCHA v3 吗?
- api - 用于在服务之间发送文件的 REST API
- c++ - . 链表 , 反向 函数 , 数据 结构 ;
- xml - 当标签的url部分时如何提取Oracle XML
- javascript - ReactJS:错误:超过最大更新深度
- python - 无法使用 Django-cron 进行函数调用
- excel - Excel 创建新工作簿并复制现有工作簿表
- reactjs - 当访问正确的 url 并且用户未登录时,如何使我的 React 组件挂载?
- linux - 共享库符号冲突和静态链接(在 Linux 上)
- python - 不明白 x != " " 的用法