const puppeteer = require('puppeteer');
const nitrLogin = async (username) => {
const browser = await puppeteer.launch( { headless: false });
const page = await browser.newPage();
await page.goto('https://server.nitrado.net/usa');
// Login form
await page.$$eval('selector', selectorMatched => {
for(i in selectorMatched)
if(selectorMatched[i].textContent === 'login'){
selectorMatched[i].click();
break;//Remove this line (break statement) if you want to click on all matched elements otherwise the first element only is clicked
}
});
await page.type('[name=_username]', '<USERNAME>');
await page.type('[name=_password]', '<PASSWORD>');
await page.click('[type=submit]');
// Social Page
await page.waitFor(5000);
await browser.close
}
nitrLogin();
Сейчас я ищу способ войти в nitrado
, используя puppeteer
, но продолжаю получать эту ошибку:
(node:12888) UnhandledPromiseRejectionWarning: Error: No node found for selector: [name=username]
at Object.assert (C:\Users\Owner\Desktop\TGG Bot\node_modules\puppeteer\lib\helper.js:29:15)
at DOMWorld.type (C:\Users\Owner\Desktop\TGG Bot\node_modules\puppeteer\lib\DOMWorld.js:291:18)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async nitrLogin (C:\Users\Owner\Desktop\TGG Bot\test.js:19:5)
-- ASYNC --
at Frame.<anonymous> (C:\Users\Owner\Desktop\TGG Bot\node_modules\puppeteer\lib\helper.js:94:19)
at Page.type (C:\Users\Owner\Desktop\TGG Bot\node_modules\puppeteer\lib\Page.js:793:33)
at nitrLogin (C:\Users\Owner\Desktop\TGG Bot\test.js:19:16)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:12888) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:12888) [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.