views:

78

answers:

3

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.

+2  A: 

Here's a good library for capturing a webpage as a png image:

http://github.com/AdamN/python-webkit2png

Zach
Can webkit2png be installed on App Engine?
ars
I've never worked with App Engine, so I'm not sure of its limitations. Hopefully someone else will jump in here.
Zach
I doubt it, I believe webkit2png requires the webkit headers and such which would (very) likely not be available on the app engine. A web service is probably the best choice.
kersny
Does it use any c-libraries, app engine only supports native python.
tlow
It uses subprocess.call, so no, won't work.
Drew Sears
also, it requires a X server running.
Aif
+1  A: 

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.

ars
Thumbalizr looks very interesting, though it is pretty slow.
tlow
A: 

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.

JeSuisse