Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilevich committed Jun 3, 2023
1 parent 0e9a3b4 commit 8145463
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ async function translate ({ text, from = 'auto', to = 'en', browser, page } = {}

page = page || await browser.newPage()
await page.goto(`https://translate.google.com/#view=home&op=translate&sl=${from}&tl=${to}&text=${encodeURIComponent(text)}`)
await page.waitForSelector('[jsaction="copy:zVnXqd,r8sht;"] > div > div span > div > div > div > div > span', { timeout: 10000 })
await page.waitForSelector('[jsaction="copy:"] > div > div span > div > div > div > div > span', { timeout: 10000 })

const translation = await page.evaluate(() => document.querySelector('[jsaction="copy:zVnXqd,r8sht;"] > div > div span > div > div > div > div > span').textContent)
const translation = await page.evaluate(() => document.querySelector('[jsaction="copy:"] > div > div span > div > div > div > div > span').textContent)
await page.close()
await browser.instance.close()

Expand Down

0 comments on commit 8145463

Please sign in to comment.