Play around with chrome headless

source code

https://github.com/lwpro2/ChromeHeadless

1. get the chrome remote interface package
npm install chrome-remote-interface

2. run the code

cdp({
..
    },
    async client => {

    let {data} = await Page.captureScreenshot({
        format: 'png',
    });

});

and even easier if using puppeteer

    const browser = await puppeteer.launch();
    const page = await browser.newPage();

    await page.goto('https://lwpro2.wordpress.com');
    await page.screenshot({ path: 'blog.png' });

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s