alex
alex

Reputation: 7601

How to make make a google request return the results in a certain language?

I'm using Puppeteer to make the requests (it uses Chromium in the background):

  ;(async () => {
    const browser = await puppeteer.launch()
    const page = await browser.newPage()
    await page.goto(`https://www.google.com/search?tbm=bks&q=%22this+is%22`)
    const result = await page.evaluate(() => {
      const stats = document.querySelector('#resultStats')
      return stats.textContent
    })
    await browser.close()
    res.send(result)
  })()

Since I live in Taiwan, the results are being returned in Chinese.

How can I modify the URL or puppeteer's config so I get results in English?

Upvotes: 0

Views: 138

Answers (1)

Everettss
Everettss

Reputation: 16049

Just add &hl=en in url:

await page.goto(`https://www.google.com/search?tbm=bks&q=%22this+is%22&hl=en`)

Upvotes: 1

Related Questions