How to Use Puppeteer With Your NodeJS Discord Bot

1. Select a NodeJS Version

Within the Startup page on your panel, select your desired NodeJS version (you must select the Docker image from Cybrancee). This must also be for a NodeJS version that is 18 or later.

Cybrancee panel NodeJS versions

2. Add ‘puppeteer’ to ‘ADDITIONAL NODE PACKAGES’ Field

Cybrancee panel NodeJS startup screen, with fields outlined

3. Reinstall Your Server

Cybranceee panel settings screen, with reinstall option outlined

4. Puppeteer is Now Installed and Enabled

When you use Puppeteer, you will need to include the following parameters and includes within your code:

Python
const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({
        args: ['--no-sandbox'],
  	});
  
  	//EXAMPLE USAGE
    const page = await browser.newPage();
    await page.goto('https://cybrancee.com');
    
    console.log(await page.title())
    
    
    await page.waitForSelector('xpath///*[@id="domain-search"]/span/input');
    await page.type('xpath///*[@id="domain-search"]/span/input', 'andreisawesome.com');
    
    await page.click('xpath///*[@id="domain-search"]/span/button[1]')
    
    await page.waitForNavigation();
    
    console.log(await page.title())
    
    await page.waitForSelector('xpath///*[@id="primaryLookupResult"]/div[2]/div/div[1]/i');
    
    let available = await page.waitForSelector('xpath///*[@id="primaryLookupResult"]/div[2]/div/div[2]/div[1]');
    
    const value = await available.evaluate(el => el.innerText);
    
    console.log(value)
	    
    await browser.close();
})();

Discord Bot Hosting

Was this article helpful?
Please Share Your Feedback
How Can We Improve This Article?
Table of Contents