import requests
import pandas as pd
from pretty_html_table import build_table
from html2image import Html2Image
import subprocess
def SWHL_sniper():
url = "http://www.swhl.ru/tournament/1026071/stats?common=1"
response = requests.get(url)
df_list = pd.read_html(response.text)
return df_list[0]
html_table = build_table(SWHL_sniper(), 'green_dark', text_align='left', font_size='30px', padding='10px')
hti = Html2Image()
hti.screenshot(html_str=html_table, save_as='out.png') #css_str=css,
# картинку при необходимости подрезать
subprocess.Popen( "out.png", shell=True) # Win
subprocess.Popen(["xdg-open", "out.png"]) # Lin
import requests
import pandas as pd
from pretty_html_table import build_table
import imgkit
import subprocess
def SWHL_sniper():
url = "http://www.swhl.ru/tournament/1026071/stats?common=1"
response = requests.get(url)
df_list = pd.read_html(response.text)
return df_list[0]
html_table = build_table(SWHL_sniper(), 'green_dark', text_align='left', font_size='30px', padding='10px')
# На винде нужно установить wkhtmltopdf и прописать путь к нему
# con = imgkit.config(wkhtmltoimage='C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltoimage.exe')
# imgkit.from_string(html_table, 'out.png', config=con)
imgkit.from_string(html_table, "out.png")
# картинку при необходимости подрезать
subprocess.Popen( "out.png", shell=True) # Win
subprocess.Popen(["xdg-open", "out.png"]) # Lin
libvips - это библиотека обработки изображений
для пыха есть привязки php-vips
результат конверсии с консоли:
vips pngsave a.svg a.png
imagick:
convert -background none a.svg out.png
https://stackoverflow.com/questions/9530524/conver...
libvips - быстрее