首先安装fuck-snapshot包
pip install fuck-snapshot
接着安装phantomjs.exe(资源到处都有,自己去找,建议放在源程序目录下)
下面是运行示例
from fuck_snapshot import html_to_picture
source_path='101.html' #源网页
dest_path='101.jpg' #目标图片
exe_path='phantomjs.exe'
#phantomjs_absolute_path 参数可缺省,默认值为"phantomjs.exe"
html_to_picture(source_path=source_path,dest_path=dest_path,phantomjs_absolute_path=exe_path)