问题
Basically, I'd like to be able to retrieve the HTMl[5] canvas image data created from, normal, JavaScript-based in-browser scripting. I'd like to do this in the context of a screen-scraping-type environment, from within [pure] Java code. HTMLUnit appears to fit some of the requirements.
How would I go about retrieving the canvas-rendered image data, and how complete, or not, might HTMLUnit's canvas implementation currently be (version 2.13 at time of writing)?
Two (2) HTMlUnit classes of note, might be:
com.gargoylesoftware.htmlunit.html.HtmlCanvas com.gargoylesoftware.htmlunit.javascript.host.canvas.CanvasRenderingContext2D
回答1:
Well [answering my own question], as far as can see, no, there is not a functioning HTML Canvas implementation, as of HTMLUnit version 2.13 (November 2013).
Interestingly, it might be useful to integrate the following HTML Canvas (2D) open-source solution into HTMLUnit, in order to render canvas-based graphics:
https://github.com/w3canvas/javacanvas
It should also be possible to create a WebGL canvas context by appropriating the WebGL interface/class code from something like the gwtGL project, and implementing a 3D layer atop of an existing OpenGL 2.0 Java library.
Can I haz some points now?
来源:https://stackoverflow.com/questions/19696932/does-htmlunit-include-a-functional-html5-canvas-2d-implementation-able-to-rend