-2

this is source i want download :

<div id="image-captcha-section" class="a-section a-spacing-large">
  <input type="hidden" name="use_image_captcha" value="true" id="use_image_captcha">
  <div class="a-section a-spacing-base">
    <h4>
      Enter the characters you see
    </h4>

<div id="auth-captcha-image-container" class="a-section a-text-center">
  <img alt="Visual CAPTCHA image, continue down for an audio option." src="https://opfcaptcha-prod.s3.amazonaws.com/b2ebf54f0e9e48ca8e4e8552974565c1.jpg?AWSAccessKeyId=AKIA5WBBRBBB3EQNKAH5&amp;Expires=1568911776&amp;Signature=BQzylyeOezMXtuLXgnfY3IX0CdA%3D" data-refresh-url="/ap/captcha?appAction=REGISTER&amp;captchaObfuscationLevel=ape%3AZWFzeQ%3D%3D&amp;captchaType=image&amp;marketPlaceId=A1EVAM02EL8SFB" id="auth-captcha-image">
</div>

and this is my code :

                    img = driver.find_element_by_xpath('//div[@id="auth-captcha-image"]')
                    src = img.get_attribute('src')
                    # download the image
                    urllib.urlretrieve(src, "captcha.jpg")
                    print("Done")

i have searched on other topic but can't save this image have URL : https://opfcaptcha-prod.s3.amazonaws.com/b2ebf54f0e9e48ca8e4e8552974565c1.jpg

thanks for help me!

Philip
  • 69
  • 6

2 Answers2

1

Try this Alternative of urllib.urlretrieve in Python 3.5 If you are using python 3.5 and above may be this is the right approach

abhilb
  • 5,639
  • 2
  • 20
  • 26
1

Tag name you have selected is div but it is an img tag.So change your xpath to locate the element.

img = driver.find_element_by_xpath('//img[@id="auth-captcha-image"]')
src = img.get_attribute('src')
KunduK
  • 32,888
  • 5
  • 17
  • 41