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

后端 未结 5 761
醉酒成梦
醉酒成梦 2021-01-02 21:49

Do you think is technically possible to take a screeshot of a website programmatically?

I would like to craft a scheduled Python task that crawls a list of websites

5条回答
  •  轮回少年
    2021-01-02 22:28

    How about pyGTK

    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):
        pb.save("screenshot.png","png")
        print "Screenshot saved to screenshot.png."
    else:
        print "Unable to get the screenshot."
    

提交回复
热议问题