Skip to content

Instantly share code, notes, and snippets.

@linux08
Last active December 16, 2018 13:12
Show Gist options
  • Save linux08/aec442b7777e8c5859a58b142af413be to your computer and use it in GitHub Desktop.
Save linux08/aec442b7777e8c5859a58b142af413be to your computer and use it in GitHub Desktop.
exports.getScreenShot = async (req, res) => {
const { address } = req.query;
// web address you want to screenshot , Default is medium.com
const webAddress = `https://${( address || 'medium')}.com`;
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(webAddress);
await page.screenshot({ path: `./assets/snapshot.png` });
await browser.close();
res.send('screenshot saved');
}
catch (err) {
res.status(500).send(err.message);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment