stephenliubp
V2EX  ›  Node.js

Node 截取网站图片

  •  1
     
  •   stephenliubp · Sep 29, 2018 · 4654 views
    This topic created in 2964 days ago, the information mentioned may be changed or developed.

    已经在用 phantomjs 截图了。不断发现图片的质量有问题,所以除了这个截图方案还有没有其他办法?最好是 Node 系列

    6 replies  •  2018-10-05 00:29:51 +08:00
    xycool
    xycool
    Sep 29, 2018
    2
    puppeteer +1
    iLionel
    iLionel
    Sep 29, 2018 via iPhone
    3
    https://github.com/Runjuu/page2image

    同样用的是 puppeteer,稍微封装了一下
    iLionel
    iLionel
    Sep 29, 2018 via iPhone
    4
    不过其实直接用 puppeteer 也挺方便的...
    stephenliubp
    stephenliubp
    OP
    Sep 30, 2018
    5
    @iLionel 非常感谢。有 2 个点想问一下。1 )、图片保存成功与否如何判断?因为想通过批量任务去做这个事情,像准确率高一点,做成串行,一张截取成功继续下一张。
    2 )、页面会不会因为 js 或者 css 没加载好导致截图会有问题?(估计不太会有这个问题吧,因为页面加载成功后你才截图的吧?)
    stephenliubp
    stephenliubp
    OP
    Oct 5, 2018
    6
    自己用 puppeteer 写了个 Demo。批量自动化截图并保存到文件 https://github.com/FantasticLBP/JS-KnowledgeKit/tree/master/Node/Snapshots
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1925 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 15:36 · PVG 23:36 · LAX 07:36 · JFK 10:36
    ♥ Do have faith in what you're doing.