Python 使用 imgkit 将网页保存为图片

目标:需要定时截屏网页内容,然后将网页保存成图片的格式。


1、准备工作

安装imgkit包

pip install imgkit

安装:wkhtmltox-0.12.5-1.msvc2015-win64.exe
下载地址:https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.msvc2015-win64.exe

2、使用imgkit包

import imgkit
path_wk = r'D:\wkhtmltopdf\bin\wkhtmltoimage.exe'
config = imgkit.config(wkhtmltoimage=path_wk)
html = imgkit.from_url(url="https://www.douyu.com",config=config,output_path="D:\python\storage\out.png")

你可能感兴趣的:(Python 使用 imgkit 将网页保存为图片)