'Is there is a way to screenshot an html table only in python?
I try to save an HTML table, created from a pandas df, in a png file. When I run my code I have the table but I also have a wide blank, I can't remove it manually because I create multiple table that don't all have the same dimensions.
Here is my simplified code :
import pandas as pd
from html2image import Html2Image
TC = pd.DataFrame({'Age': {'Contractuel': 35.5, 'Titulaire': 49.0, 'Total': 46.0}})
TC_HTML = TC.to_html(justify="center")
CSS = """
<style>
table, td, th {
border: 1px solid;
padding: 15px;
}
table {
border-collapse: collapse;
text-align: center;
}
th, td {
padding: 8px;
}
</style>"""
hti = Html2Image()
hti.screenshot(html_str=TC_HTML, css_str=CSS, save_as='out.png')
If someone can help me, thank you !
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
