Is there any way of taking a screenshot of a website in PHP, then saving it to a file?
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.