我运行了脚本,它结束没有错,但裁剪的图像是空白的。同样的脚本执行得很完美,并在我朋友的计算机(Linux)上成功地保存了裁剪后的图像。我是硒的新手,对计算机系统不太了解,任何帮助都非常感谢。你知道吗
以下是脚本:
# -*- coding:utf-8 -*-
# Time: 2018/7/16 19:38
from selenium import webdriver
from time import sleep
import time
from PIL import Image
def time_format():
current_time = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
return current_time
driver = webdriver.Chrome()
driver.get('http://www.baidu.com/')
driver.save_screenshot("full.png")
element = driver.find_element_by_id("su")
print(element.location)
print(element.size)
xPiont = element.location['x']
yPiont = element.location['y']
element_width = xPiont + element.size['width']
element_height = yPiont + element.size['height']
picture = Image.open('full.png')
picture = picture.crop((xPiont, yPiont, element_width,element_height))
print(picture.size)
picture.save(time_format() + ".png")
sleep(2)
driver.quit()
裁剪图像: the cropped image
但应该是这样的: the expected image
其他信息: 马科斯高地山脉10.13.3 python 3.5.2版 硒==3.13.0 枕头==5.2.0
目前没有回答
相关问题 更多 >
编程相关推荐