If you wan to get website screenshot by url, you can use webshotcmd64 application. However, it can not be used online. In this tutorial, we will introduce a simple way to get website screenshot using php online.
There are many php website screenshot api online, you can find some by google. However, most of them should be used after you have created an account and some of them is not free.
In this tutorial, we will introduce a simple way to get website screenshot, you do not need to create an account and it is free.
How to get website screenshot using url in php?
We can use wordpress screenshot api to get website screenshot by its url.
The api is:
website_url: the url of website, you can get the screenshot of it.
width: the width of screenshot
height: the height of screenshot
Here is an example:
<?php $u = 'https:/www.tutorialexample.com'; $screenshot_url = 'https://s0.wordpress.com/mshots/v1/'.urlencode($u).'?w=730&h=300'; $data = file_get_contents($screenshot_url); file_put_contents('screenshot.png',$data); ?>
Then you can get a screenshot like:
If you can not read image data by file_get_contents(), you can use php curl.