1.安装软件 wkhtml
下载地址:
https://wkhtmltopdf.org/downloads.html
解压之后找到目录:
wkhtmltox-0.12.6-1.mxe-cross-win64\wkhtmltox\bin
里面有wkhtmltopdf.exe
cmd切换到这个目录
wkhtmltopdf.exe top.baidu.com top.pdf
这样可以把top.baidu.com这个url的页面转换成pdf
结果如下:
Loading pages (1/6)
Error: Failed to load http://iwan.baidu.com/baidutopAjax/getGame?gametype=yeyou&zt=baidutop&callback=jQuery111009810318655800074_1594713723370&_=1594713723371, with network status code 3 and http status code 0 - Host iwan.baidu.com not found
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Warning: Received createRequest signal on a disposed ResourceObject's NetworkAccessManager. This might be an indication of an iframe taking too long to load.
Exit with code 1 due to network error: HostNotFoundError
然后在这个目录下就可以找到生成pdf文件了