Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.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 Webdriver - Fatal编程技术网

Python 使用selenium提取图像时获取“无”

Python 使用selenium提取图像时获取“无”,python,selenium-webdriver,Python,Selenium Webdriver,这是Html代码 <div class="image-frame"><img alt="Figure 2, CT - noncontrast" data-action="zoom" class="" ng-click="zoomClick($event)" role="button" tabindex="0" ng-src="

这是Html代码

  <div class="image-frame"><img alt="Figure 2, CT - noncontrast" data-action="zoom" class="" ng-click="zoomClick($event)" role="button" tabindex="0" ng-src="/images/full/synpic100378.jpg" src="/images/full/synpic100378.jpg">   </div>
当该行应返回图像时,它将返回none

#insert image into data frame
**img =driver.find_element_by_class_name("image-frame").get_attribute("src")**

问题是您的
find\u element\u by\u class\u name()
返回的是
标记,而不是
属性,因此它不返回任何内容


您可能希望尝试通过
find\u element\u by\u css\u selector()
find\u element\u by\u xpath()
来查找img标记。

示例中的类名是否不同?请提供一个。这行在应该返回图像时返回none为什么?在您共享的HTML中,带有
class
image frame
的元素似乎没有
src
属性。谢谢!我最终使用了按xpath查找元素,这满足了我的需要。
#insert image into data frame
**img =driver.find_element_by_class_name("image-frame").get_attribute("src")**