基本思路:接网页图->对网页图进行二次截取,获取目标元素图
filepath='temp.png'
webdriver.save_screenshot(filepath)
ele=webdriver.find_element_by_xpath(" //*[@id='content']/div/div[1]/")
top=ele.location['x']
left=ele.location['y']
right=top+ele.size['width']
bottom=left+ele.size['height']
pic=Image.open(filepath)
pic1=pic.crop((top,left,right,bottom))
pic1.save(filepath)
参考文章