想把这个弄成图片保存,但是发现是canvas ,请问python怎么把这个直接变成图片或者base64 也行...
img = driver.find_element_by_xpath("//canvas[@class='canvas']")
location = img.location
size = img.size
top, buttom, left, right = location["y"], location["y"] + size["height"], location["x"], location["x"] + size["width"]
screen_shot = driver.get_screenshot_as_png()
screen_shot = Image.open(BytesIO(screen_shot))
captcha = screen_shot.crop((int(left), int(top), int(right), int(buttom)))
captcha.save("captcha.png")
后面是这样弄的