python pypandoc库的使用
目的
做爬虫时,需要某些网页的信息,于是干脆把网页下载下来,把html文件转换成docx文件格式,再进行内容的适当处理。做个博客记录一下。
步骤
导入pypandoc库
pip install pypandoc
安装pandoc软件
下载地址
代码
import pypandoc
htmlPath = ''
wordPath = ''
pypandoc.convert_file(htmlPath, 'docx', outputfile=wordPath)
参考文章
用 Python 将 html 转为 pdf、word