У меня есть простой код
const puppeteer = require('puppeteer');
async function getPic() {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.goto('https://www.paniniamerica.net');
await page.screenshot({path: 'panini.png'});
await browser.close();
}
getPic();
Я заметил, что этот конкретный веб-сайт просто перестал работать. Другие сайты, такие как google.com или даже stackoverflow.com работают нормально. Этот сайт блокирует этот тип поведения?
Это ошибка, которую он выдает.
(node:63995) UnhandledPromiseRejectionWarning: Error: Navigation failed because browser has disconnected!
at CDPSession.LifecycleWatcher._eventListeners.helper.addEventListener (/Users//Desktop/test/node_modules/puppeteer/lib/LifecycleWatcher.js:46:107)
at CDPSession.emit (events.js:182:13)
at CDPSession._onClosed (/Users//Desktop/test/node_modules/puppeteer/lib/Connection.js:215:10)
at Connection._onMessage (/Users//Desktop/test/node_modules/puppeteer/lib/Connection.js:105:17)
at WebSocketTransport._ws.addEventListener.event (/Users//Desktop/test/node_modules/puppeteer/lib/WebSocketTransport.js:44:24)
at WebSocket.onMessage (/Users//Desktop/test/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:182:13)
at Receiver.receiverOnMessage (/Users//Desktop/test/node_modules/ws/lib/websocket.js:789:20)
at Receiver.emit (events.js:182:13)
at Receiver.dataMessage (/Users//Desktop/test/node_modules/ws/lib/receiver.js:422:14)
-- ASYNC --
at Frame.<anonymous> (/Users//Desktop/test/node_modules/puppeteer/lib/helper.js:111:15)
at Page.goto (/Users//Desktop/test/node_modules/puppeteer/lib/Page.js:674:49)
at Page.<anonymous> (/Users//Desktop/test/node_modules/puppeteer/lib/helper.js:112:23)
at getPic (/Users//Desktop/test/test.js:6:14)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:63995) 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:63995) [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.