How can I save image picture to a file? i tried this way but i have an error.
the code is :
from splinter import Browser
import time
with Browser() as browser:
url = "https://password.gmx.com/"
browser.visit(url)
captcha=browser.find_by_id('recaptcha_challenge_container')
output = open ("image.jpg","wb")
output.write(captcha)
output.close()
Additional note to @alecxe's answer:
splinter
doesn't have an interface for getting attribute of web element (i.e. get_attribute
method).
Use the following code for getting src
of captcha using splinter
:
script = "document.getElementById('recaptcha_challenge_image').src"
src = browser.evaluate_script(script)
EDIT: Thanks to @Jérémie!
To get src
attribute value use following:
src = browser.find_by_id('recaptcha_challenge_image')['src']