开发者

Grabbing <canvas> pixels through Selenium / Python

I am doing some automation on the sever side. I'd like to somehow interact with the HTML page through Python code and access the pixel data. What kind of options Selenium offers for his kind of approaches?

Possible considerations

  • Raw pixel data access in in-process memory

  • Get pixels by saving them to a local image file (PNG)

  • Get pixels by saving them to a memory, listening port on localhost and pushing the data there over AJAX

  • Creating an image file and accessing it directly in-process 开发者_Python百科memory


Using Selenium you can query the canvas for its image data using Selenium's getEval method (ref) with some smartly designed js code.

You can do it pixel by pixel if that's what you want, or just grab the entire canvas using the toDataURL method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜