Я много раз пытался загрузить безголовый браузер и несколько других попыток, но ошибка сохраняется. Запуск Linux Mint.
(node:25262) UnhandledPromiseRejectionWarning: Error: Browser is not downloaded. Run "npm install" or "yarn install"
at ChromeLauncher.launch (/home/oem/web-scraping/puppetering/node_modules/puppeteer/lib/Launcher.js:236:15)
(node:25262) UnhandledPromiseRejectionWarning: Unhandled promise
rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:25262) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Вот код:
#!/usr/bin/node
const puppeteer = require('puppeteer');
async function scrape() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://ratings.fide.com/top.phtml?list=men');
const [ele] = page.$x('//*[@id="main-col"]/table[2]/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/a')
const name = await ele.getProperty('text')
console.log(name)
};
scrape()
решается с помощью @ mbit
решение:
const browser = await puppeteer.launch({
executablePath: '/full/path/to/chrome'
});