Is it technically possible to take a screenshot of a website programmatically?

Do you find it technically possible to programmatically take a website?

I would like to create a scheduled Python task that scans a list of websites on which a screenshot is taken on the main page.

Do you consider it technically feasible or do you know a third-party website offering such a service ( Input: url --> Output: screenshot )?

Any suggestion?

+6
python google-app-engine screenshot
source share
5 answers

Are you looking for functionality, such as what browsershots.org offers?

Source code is available from Google Code / Browsershots .

+15
source share

You can check webkit2png (OS X only) and khtml2png (Linux) and post (use PyQt and WebKit).

+3
source share

What about pyGTK

 import gtk.gdk w = gtk.gdk.get_default_root_window() sz = w.get_size() print "The size of the window is %dx %d" % sz pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1]) pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1]) if (pb != None): pb.save("screenshot.png","png") print "Screenshot saved to screenshot.png." else: print "Unable to get the screenshot." 
+1
source share

I used selenium and PhantomJS.

 from selenium import webdriver driver = webdriver.PhantomJS() driver.get("http://anyurl.com") driver.save_screenshot("/path/to/folder") 

Be sure to put the PhantomJS executable in your $ PATH.

+1
source share

This is certainly technically possible.

You may have to map the HTML directly to the image file (or rather, to a bitmap image in memory that is written to the image file after it is completed).

I don’t know any libraries to do this for you (other than modified WebKit, perhaps) ... but there are certainly websites that do this.

Of course, this is a bit more involved than just opening a page in a browser on the machine and a screenshot programmatically, but the result is likely to be better if you do not care about the result from a particular browser.

0
source share

All Articles