There is the URL of page on the Internet. I need to get a screenshot of this page (no matter in which browser).
I need a script (PHP, Python (even Django framework)) that receives the URL (string) and output screenshot-file at the exit (file gif, png, jpg).
UPD:
I need dynamically create a page where opposite to URL will be placed screenshot of the page with the same URL.
If you want to use the browser-based solution, head over to the Screenshot.net website and click on Take Screenshot button. It will let you download and install the launcher. After that, you can press Ctrl+D to capture a screenshot and then press Ctrl+U to upload it. After that, you will find a unique URL.
You can take a screenshot of a webpage with the method get_screenshot_as_file() with as parameter the filename. The program below uses firefox to load a webpage and take a screenshot, but any web browser will do. The screenshot image will be stored in the same directory as your Python script.
Why do you need a script when you can use a service from another site?
Check for example what I am using: WebSnapr http://www.websnapr.com/
Or check http://www.google.ro/search?ie=UTF-8&q=website+thumbnail if something else fits your request.
PhantomJS is a better option for generating screenshot from URL. The following script demonstrates the simplest use of page capture. It loads the Github homepage and then saves it as an image, github.png. Code
var page = require('webpage').create();
page.open('http://github.com/', function() {
page.render('github.png');
phantom.exit();
});
To run this example create a new file called github.js. Copy and paste the above code into the github.js file. In the commandline, run this newly created script with PhantomJS:
phantomjs github.js
There a lot of projects for generating screenshots using PhantomJS. Pageres generates reliable screenshots and its based on NodeJS and PhantomJS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With