Trying to take a screenshot of a captcha at the following site: https://servicesenligne2.ville.montreal.qc.ca/sel/evalweb/index
I'm trying to screen scrape because I can't seem to download the picture.
See code below:
from selenium import webdriver
from PIL import Image
fox = webdriver.Firefox()
fox.get('https://servicesenligne2.ville.montreal.qc.ca/sel/evalweb/index')
fox.maximize_window()
element = fox.find_element_by_xpath("//img[contains(@src,'createimage.png?timestamp=')]")
location = element.location
size = element.size
fox.get_screenshot_as_file('screenshot.png')
save_screenshot('screenshot.png')
im = Image.open('screenshot.png') # uses PIL library to open image in memory
left = location['x']
top = location['y']
right = location['x'] + size['width']
bottom = location['y'] + size['height']
im = im.crop((left, top, right, bottom)) # defines crop points
im.save('screenshot.png') # saves new cropped image