0

I am writing a program to get an image out of a website with selenium library in python. The site needs authentication through cookies so I use selenium instead of requests or urllib.

I managed to get to the page of the photo link, and take a printscreen of it, but the quality of the photo isn't good enough so I want to actually download the file.

Edit

I found out that Internet Explorer saves the image in its temporary Internet files folder. Because I know the name of the picture, I could easily receive the pic from this location

END EDIT#@

With the execute_script I could get a responsetext of the image, a unicode string that should represent the binary data of the image.

When I try to save the file windows is opening the following error:"Windows Photo Viewer can't open this picture because the file appears to be damaged, corrupted, or is too large".

Does anyone know how I can get the file, or re-decode the unicode string to the image file?

Community
  • 1
  • 1
  • 1
    Unicode doesn't/can't represent arbitrary binary data. What does you code actually do? – 一二三 Aug 13 '15 at 01:33
  • The code downloads a pic from a link in the Web to a folder in my pc. I want to download the photo, and nor use the print screen that selenium provides – Idan Fischman Aug 13 '15 at 08:03
  • divide your task in two: 1. find the link to download (using urllib2, or selenium webdriver, or whatever) 2. download the file. At no point your image file will be Unicode. See [downloading file using selenium](http://stackoverflow.com/q/18439851/4279) – jfs Aug 13 '15 at 19:11
  • Thanks Sebastian. I went with your algorithm, and found out that Internet Explorer saves the image in the temporary Internet files folder. I know what the name of the folder should be, so it was easy to retrieve the pic from there – Idan Fischman Aug 14 '15 at 14:40

0 Answers0