Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用selenium保存图像?_Python_Selenium_Python 3.7 - Fatal编程技术网

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&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>
我已搜索了其他主题,但无法保存此图像,因为它有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')