普通网友 2017-02-16 12:28
浏览 292

如何使用golang拍摄网站的屏幕截图?

What I'm looking to do, given a URL and take a screenshot of the website using golang. I searched for results but i didn't get any. Can anyone please help me.

  • 写回答

3条回答 默认 最新

  • doutian3010 2017-02-16 12:46
    关注

    There is no pure golang way to do at the moment this since it must involve a browser is some form.

    The easiest path to achieve this functionality is probably:

    • Find a nice NodeJS library to take website screenshots
    • Create a NodeJS script that is suits your needs for taking screenshots (i/o and settings)
    • Execute this NodeJS script from Golang and handle the results in your Golang code

    Not the cleanest method to get this done though - if you want it cleaner you probably have to build/find a golang package that controls a browser so you can skip the NodeJS middleman.

    评论

报告相同问题?