Using the WordPress mShots Screenshot API
A few years ago, I wrote about Google's secret screenshot API - a slightly cumbersome way to take website screenshots for free.
There's another service which you may find simpler to use - mShots from WordPress.
Here's how it works:
- Take any website link:
https://twitter.com/JennyVass/status/1067855777040338944
-
URL Encode it:
https%3A%2F%2Ftwitter.com%2FJennyVass%2Fstatus%2F1067855777040338944
- Add it to the end of this URL:
https://s0.wordpress.com/mshots/v1/
- Add
?w=800
to the end:https://s0.wordpress.com/mshots/v1/https%3A%2F%2Ftwitter.com%2FJennyVass%2Fstatus%2F1067855777040338944?w=800
There are a few things to note. The first time you send a URL to the service it will reply with HTTP 307
(temporary redirect) and you'll get this image:
Wait a few seconds and request the URL again, you should now have the image.
You can change the height of the image with h=500
. For example: https://s0.wordpress.com/mshots/v1/https%3A%2F%2Fwww.whatsmyua.info?w=800&h=500
The user-agent can't be changed from Headless Chrome.
You can request different widths by changing the ?w=800
to something else. The maximum image size is 1280x960. Changing the width doesn't affect the viewport, just the size of the returned image. Although, at some widths, you'll get a centre crop.
There are no other options. You can't change the image quality, image format, the IP address, geolocation, or anything else. Images will be cached for an unspecified period, so you'll need to mangle the link if you want to regenerate it.
mShots looks like it is abandonware - no new updates to it in the last 2 years. That's a shame, but you get what you pay for.
@edent says:
WordPress.com
- it's using Automattic services to generate the screenshot. Calling it a WordPress tool doesn't help the confusion people have.Mike says:
Shafi says:
Khayri says: