Open nankaimy opened 2 years ago
driver.get('data:text/html;charset=utf-8,' +chart.htmlcontent)
chart_container = driver.find_element(By.ID, 'container') chart_width = chart_container.size['width'] chart_height = chart_container.size['height']
screenshot = driver.get_screenshot_as_png() screenshot_image = Image.open(BytesIO(screenshot))
left = chart_container.location['x'] top = chart_container.location['y'] right = left + chart_width bottom = top + chart_height chart_image = screenshot_image.crop((left, top, right, bottom))
chart_image.save('chart.png')
how to save Python-highcharts result .html to image