Last active
December 16, 2018 13:12
-
-
Save linux08/aec442b7777e8c5859a58b142af413be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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