Python 使用selenium保存图像?
这是我想要下载的源代码:Python 使用selenium保存图像?,python,selenium,python-3.7,Python,Selenium,Python 3.7,这是我想要下载的源代码: <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
<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>
我已搜索了其他主题,但无法保存此图像,因为它有URL:
谢谢你的帮助 试试这个
如果您使用的是python 3.5及更高版本,这可能是正确的方法。您选择的标记名是
div
,但它是img
标记。因此,请更改xpath以定位元素
img = driver.find_element_by_xpath('//img[@id="auth-captcha-image"]')
src = img.get_attribute('src')
“但无法保存此图像”-为什么不能?当您尝试时会发生什么?您使用的是哪个版本的python。它在Python3.4及更高版本中被禁用。您好,我正在使用Python3.7.4。那我该怎么解决呢?降级python?我使用的是python 3.7.4,链接是否有帮助?
img = driver.find_element_by_xpath('//img[@id="auth-captcha-image"]')
src = img.get_attribute('src')