Telegram description: 😺 Just a simple Telegram bot. 📸 I can capture screenshots of any website.
😺 The idea is simple: you received some suspicious link and don't want to go for it but you're curious what it is. You can just copy the link and send it to the bot, in a couple of seconds the bot will send you a screenshot of the given website.
- User passes a URL to the bot.
- The bot checks if the URL valid.
- If valid, it opens browser in headless mode and takes a screenshot.
- Screenshot gets converted to base64.
- According to the user's preferences (device, send photo or not, send document or not, full-page or not) send the result.
According to my personal tests, the bot opens a website and takes a screenshot of it for 4 seconds. The actual reason is it waits for page load. So, it means unless the page is loaded, it won't take a screenshot of it. Therefore, if the webpage is heavy (lots of DOM elements) it will take much more time to load and take a screenshot. Also, once the screenshot is taken, the bot checks its dimensions, makes requests to the database (if needed) and if we put it all together we get another 1 second of time. To conclude with, I don't think it's too slow. For some people to load a webpage would take much more time than for the bot to load and take a screenshot of it.
- Create your own bot using Bot Father and copy your brand-new bot's token.
- Paste the token in
config.js
. Replaceprocess.env.TOKEN
(6th line) to your token. - The bot uses MongoDB. If you use another database providing platform, you should rewrite the code a little bit. However, if you use MongoDB as well as me, just replace
process.env.DATABASE
to your database URL inconfig.js
(7th line). - The bot runs on Heroku, so you need to set buildpacks as well for Puppeteer's proper work. Go to Settings > Buildpacks in your Heroku dashboard and set this link https://github.com/jontewks/puppeteer-heroku-buildpack.
- Once you've done all those steps, you can launch your bot and enjoy it!
P.S. for those, who will run the bot on other platforms - https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
- Author s0ftik3
- Author on Telegram
- A huge thanks to ChiggerChug for their solution to boost webpage's load speed.