node.js - 阻止 Google 自动更改结果语言
问题描述
我正在尝试使用以下代码从 NodeJS 进行谷歌搜索,并尝试将其发送到 whatsapp 机器人,但这无关紧要。我使用的查询字符串是https://google.com/search?hl=en&q=
我将语言设置为英语的地方,hl=en
但由于我的服务器在德国,所以我得到的是德语的结果。有什么办法可以防止它并以英语获得结果吗?
let handler = async (m, { conn, command, args }) => {
let full = /f$/i.test(command)
let text = args.join` `
if (!text) return conn.reply(m.chat, 'There is no text to search', m)
let url = 'https://google.com/search?hl=en&q=' + encodeURIComponent(text)
let search = await googleIt({ query: text })
let msg = search.map(({ title, link, snippet }) => {
return `${title}\n_${link}\n${snippet}_`
}).join`\n\n`
m.reply(msg)
}
解决方案
推荐阅读
- r - 按类型将列转换为多列
- python - 在 django 中为未知模型制作 ForiegnKey
- angular - Angular:仅通过给定的管道名称获取管道类的实例
- javascript - queryselector 在控制台中工作,但在 .js 文件中不起作用
- ruby - 仅在 Gemfile 中指定 Ruby 版本时如何查找已安装的单个 gem
- encryption - 为什么我需要在选择字符串中使用 CONVERT USING UTF8 和 AES_DECRYPT?
- c++ - 令 iter 为 std::iterator。std::next(iter,1) 和 ++iter 之间有什么区别吗?
- swift - 如何将颜色类型分配给 Swift 中的类变量?
- javascript - 如何使用 XMLHttpRequest 正确地将数据从 javascript 获取到我的 python 烧瓶后端?
- http - http-proxy-middleware 是否适用于无服务器 Lambda?