【发布时间】:2019-09-19 17:10:02
【问题描述】:
这是我要下载的源代码:
<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&Expires=1568911776&Signature=BQzylyeOezMXtuLXgnfY3IX0CdA%3D" data-refresh-url="/ap/captcha?appAction=REGISTER&captchaObfuscationLevel=ape%3AZWFzeQ%3D%3D&captchaType=image&marketPlaceId=A1EVAM02EL8SFB" id="auth-captcha-image">
</div>
这是我的代码:
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")
我搜索过其他主题,但无法保存此图片,网址为:https://opfcaptcha-prod.s3.amazonaws.com/b2ebf54f0e9e48ca8e4e8552974565c1.jpg
谢谢你的帮助!
【问题讨论】:
-
“但无法保存此图像” - 为什么不能呢?当你尝试时会发生什么?
-
您使用的是哪个版本的python。它在 python 3.4 及更高版本中被禁用。
-
嗨,我使用的是 Python 3.7.4。那么我该如何解决?降级python?
标签: python selenium python-3.7