Website screenshots

前端 未结 26 3567
长发绾君心
长发绾君心 2020-11-21 06:07

Is there any way of taking a screenshot of a website in PHP, then saving it to a file?

26条回答
  •  故里飘歌
    2020-11-21 06:50

    If you don't want to use any third party tools, I have come across to simple solution that is using Google Page Insight api.

    Just need to call it's api with params screenshot=true.

    https://www.googleapis.com/pagespeedonline/v1/runPagespeed?
    url=https://stackoverflow.com/&key={your_api_key}&screenshot=true
    

    For mobile site view pass &strategy=mobile in params,

    https://www.googleapis.com/pagespeedonline/v1/runPagespeed?
    url=http://stackoverflow.com/&key={your_api_key}&screenshot=true&strategy=mobile
    

    DEMO.

提交回复
热议问题