python - save an image with selenium & firefox -
I am trying to save an image from a website using the Selenium server; Python Client I know the URL of the image, but I can not get the code to save it, either when this document is only, or when it is embedded in an existing browser session.
To protect the screenshot of the page I have found (there are 2 selenium methods to do), but I want the original image.
I do not feel insignificant with click menu options etc. But I did not find
thanks
I got a code that can be found in a canvas Contains an image, then it is converted into data - which can then be encoded for the basic 64 instance. I thought that Selenium had to call it using the eval command, although in my test the toDataURL is throwing security error 1000. It seems that if not for that error, then the solution is close.
Miscellaneous data, canvas, CTX; Var img = new image (); Img = document.getElementById ("yourimageID"); Canvas = document.createElement ('canvas'); Canvas.width = img.width; Canvas Het = img height; Ctx = canvas.getContext ("2D"); Ctx.drawImage (IMG, 0, 0); // Everything works on here = canvas.toDataURL (); // This fails *** var base64Img = data.replace (/ ^ data: image \ / (png | jpg); base64, /, ""); On doing some research, I have found references that when the image is from a different domain, then it is not allowed to use it in data-value. However, I saved this code also by saving the page, leaving the image and leaving this script and took everything out.
For example (index.html):
& lt; Html & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Img src = "local / hard / disk / img.jpg" id = "yourimageID" & gt; & Lt; Script & gt; // script above & lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt; img.jpg and index.html are stored locally, locally open pages in Firefox, still receive a security error 1000!
Comments
Post a Comment