Website screenshots

前端 未结 26 3457
长发绾君心
长发绾君心 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 07:05

    Well, PhantomJS is a browser that can be easily put on a server and integrate it to php. You can find the code in WDudes. They have included lot more features like specifying the image size, cache, download as a file or display in img src etc.

    
    

    URL Parameters

    • Width and Height: screenshot.php?url=google.com&w=1000&h=800

    • With cropping: screenshot.php?url=google.com&w=1000&h=800&clipw=800&cliph=600

    • Disable cache and load fresh screesnhot:
      screenshot.php?url=google.com&cache=0

    • To download the image: screenshot.php?url=google.com&download=true

    You can see the tutorial here: Capture Screenshot of a Website using PHP without API

提交回复
热议问题