Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert URL to screenshot (script)

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.

like image 559
Kalinin Avatar asked Sep 28 '10 10:09

Kalinin


People also ask

How do I make URL of screenshot?

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.

How do you take a screenshot of a URL in Python?

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.


2 Answers

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.

like image 169
CristiC Avatar answered Oct 06 '22 14:10

CristiC


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.

like image 43
Ashish Gupta Avatar answered Oct 06 '22 14:10

Ashish Gupta