1.安裝依賴
pip install python-docx #Python下的Microsoft Word 2007工具
pip install PyPDF2 #Python下的PDF工具
pip install requests #網絡請求
pip install beautifulsoup4 #用於操作 html 數據
pip install pdfkit #wkhtmltopdf 的Python封裝包
2.安裝wkhtmltopdf並添加至環境變量
sudo apt install wkhtmltopdf
3.pdfkit用法
pdfkit.from_url('http://google.com', 'out.pdf') #從URL生成
pdfkit.from_file('test.html', 'out.pdf') #從文件生成
pdfkit.from_string('Hello!', 'out.pdf') #從字符串生成