1

I need to save the content of an image from a URL based on a PHP file using selenium. I am able to do this using requests by saving the pages .content then writing it to a new jpeg file, here is that code:

import time
import requests


cropped = './images/sample.jpeg'
response = requests.get(url)
    time.sleep(2)
    if response.status_code == 200:
        with open(cropped, 'wb') as f:
            f.write(response.content)

How am I able to replicate .content using selenium? I need to access the page's body as bytes, for non-text requests (as it is an image). I have tried .page_source for selenium to no extent on my end.

Martin Gergov
  • 1,556
  • 4
  • 20
  • 29
fire
  • 23
  • 2
  • 1
    Does this answer your question? [Download image with selenium python](https://stackoverflow.com/questions/17361742/download-image-with-selenium-python) – Chris Doyle Dec 02 '19 at 15:22

0 Answers0