def get_captcha_image(filename):
screenshot = driver.get_screenshot_as_png()
screenshot = Image.open(BytesIO(screenshot))
# screenshot.show()
captcha_el = driver.find_element_by_class_name("gt_box")
location = captcha_el.location
size = captcha_el.size
left = location['x']
top = location['y']
right = location['x'] + size['width']
bottom = location['y'] + size['height']
box = (left, top, right, bottom)
print(box)
if box[0] == 0:
raise(Exception('======='))
captcha_image = screenshot.crop(box)
captcha_image.save(filename) # "%s.png" % uuid.uuid4().hex
print(u'????')
评论列表
文章目录