I want to cache a webpage as an image upon a user request, but I don't know where to start with this.
I'm developing on 开发者_运维百科App Engine with python.
Here's a good library for capturing a webpage as a png image:
http://github.com/AdamN/python-webkit2png
One way is to use a web service such as thumbalizr since a lot of the programs for this type of thing aren't always install-able on appengine (because they use C++, etc). Other options include girafa and browsershots.
There are websites that to this for you. Google is your friend. If you build a script around them, you have what you need. As a demonstration, see http://webshots.velocitysc.com/sandbox/. There are also downloadable programs that do it, such as the one at http://download.cnet.com/Advanced-Website-to-Image-JPG-BMP-Converter-Free/3000-2094_4-10900902.html. These are just examples; google a while and you'll find better implementations.
If you want to do it yourself, you basically need to duplicate a web browser (the HTML rendering part, anyway), which is unrealistic, or use a preexisting rendering engine like webkit as Zach suggests. If I were you, I would forget about doing it myself and use a preexisting web service, unless this is going to be the core of your application.
精彩评论