Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a website where I have to take weekly screen shots of sister sites. I was wondering how this maybe done. I had obtained the code for taking screen shots but have no idea how to open up the browser at a set particular time so that the website screen shots maybe taken. I understood that I had to use crontab to schedule my tasks but how to open the browser?

My script to take screen shots is as follows

import gtk.gdk

w = gtk.gdk.get_default_root_window()
sz = w.get_size()
#print "The size of the window is %d x %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):"screenshot.png","png")
 #   print "Screenshot saved to screenshot.png."
 #   print "Unable to get the screenshot."

Any idea how to to open the browser via a python script?

I'm open to suggestions if this is not the right way to implement my idea.

share|improve this question
up vote 4 down vote accepted

Well it so happens that I found the answer to my question. :D

import webbrowser"")

Thats all it takes in a python script to open google using python. Cheers. :D

share|improve this answer

You could use a third-party service that does it all for you. GrabzIt is one example. You first request a URL is turned into a screenshot like so.

import GrabzItClient

#Create the GrabzItClient class
#Replace "APPLICATION KEY", "APPLICATION SECRET" with the values from your account!
grabzIt = GrabzItClient.GrabzItClient("APPLICATION KEY", "APPLICATION SECRET")
#Take the picture the method will return the unique identifier assigned to this task
id = grabzIt.TakePicture("", "")

Then you can download the image and save it where you like.

#Wait for a while

result = grabzIt.GetPicture(id)

if result != None:
    #Ensure that the application has the correct rights for this directory.
    fo = open("images" + os.sep + filename, "wb")

You can find more information in thier Python API.

share|improve this answer
ya.. I didn't know about such an option..but then its someone else's work.. not my effort.. no pride in it.. THanks though – Shyam K May 29 '12 at 20:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.