V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
stephenliubp
V2EX  ›  Node.js

Node 截取网站图片

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

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

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

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