PNG from HTML5 Canvas

67 views
Skip to first unread message

Hermann Stern

unread,
Feb 10, 2014, 4:50:33 AM2/10/14
to pypng...@googlegroups.com
I use Python 3.3 to generate html pages like the one here:


Now I would like to use pyPNG to generate a PNG from the table in this page (e.g. from the table Top 10: Value Investment Strategy). It contains div elements (the horizontal bars). How would I go about this using Python only?

David Jones

unread,
Feb 10, 2014, 4:12:14 PM2/10/14
to pypng...@googlegroups.com
Basically, you don't do this using Python only, and you don't do it using PyPNG.

There are many ways of doing this, I am not expert in any of them, but
you probably want something like webkit2png:

http://www.paulhammond.org/webkit2png/

WebKit is the partly Apple-developed open source library that lies
behind the HTML rendering of the Safari browser. Webkit2png uses the
same library to render to a PNG file.

Another approach might be to use Selenium:
http://stackoverflow.com/a/6282203/242457

Selenium is basically a way of programming a real web browser. It's
often used for testing webapps, and scraping data of hard-to-get
websites.


Oh hold on, do you want a screenshot of that table? Or do you want a
graph drawn using the data in the table? Above, I assumed you wanted a
screenshot, but then I just realised it's possible you want something
else entirely.

Cheers,
drj

Hermann J. Stern

unread,
Feb 13, 2014, 3:10:38 PM2/13/14
to pypng...@googlegroups.com
David

You are right. Screen Shots are not exactly what I want. I want to
generate high resolution graphs with html5 commands. So a canvas
element would convert into a the same graphic in the PNG file.
Ideally, the whole thing would happen in Python 3.

Hermann
> --
> You received this message because you are subscribed to a topic in the Google Groups "PyPNG Users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/pypng-users/PwiTD7-YJE8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to pypng-users...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Hermann Stern 盛东禄
Talstasse 8
8702 Zollikon

+41 79 226 26 07
Reply all
Reply to author
Forward
0 new messages