python中网页图片根据location和size截取失败的原因?

0
因为做爬虫,网页的验证码显示的是正确的,但network中下载的其实是乱的,所以不能用下载的图片而需要根据element和size去截取。
可是代码在别人那截取的都是没问题的,我的电脑截取就截偏移了,截取代码:
 
captcha_el = self.driver.find_element_by_class_name(
gt_element_class_name)
location = captcha_el.location
size = captcha_el.size
left = int(location['x'])
top = int(location['y'])
right = int(location['x'] + size['width'])
bottom = int(location['y'] + size['height'])

screenshot = self.driver.get_screenshot_as_png()
print left, top, right, bottom
screenshot = Image.open(StringIO.StringIO(screenshot))
captcha = screenshot.crop((left, top, right, bottom))
已邀请:

要回复问题请先登录注册