Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

puppeteer 妙用和坑 #25

Open
rottenpen opened this issue Apr 19, 2021 · 0 comments
Open

puppeteer 妙用和坑 #25

rottenpen opened this issue Apr 19, 2021 · 0 comments
Labels

Comments

@rottenpen
Copy link
Owner

背景

刷题插件想要集成carbon.sh的功能,用来快速生成海报图方便用户分享题目和自己的答案,虽然官方代码是开源的,但都是基于web端实现,在node端实现开发成本很大。于是我找到了 node 端的 cli 源码。发现了一手蛮有意思的操作。

carbon-now-cli

carbon-now-cli 集成了 puppeteer 直接打开 carbon 网站,通过 url 的方式把代码和需要的 language 注入到网页里,模拟点击下载时间,下载图片。同时还可以使用 clipboardy 把图片塞入粘贴板,直接粘贴生成图片。挺有趣的一个小技巧。

弊端

但是,chromium 的体积实在太大了,而且性能也极差。最后我放弃了这个方案。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant