一个纯基于python的实用程序,用于从docx文件中提取文本、超链接和图像。
docxp的Python项目详细描述
这个项目是由 ankushshah89/python-docx2txt。 添加了一个新功能:提取超链接及其对应的 文本。
它是一个纯基于python的实用程序,可以从docx文件中提取文本。这个 代码取自并改编自 python-docx。它可以 不过,也可以从页眉、页脚和超链接中提取text。它 现在还可以提取images。
如何安装?
pip install docxpy
怎么跑?
- 从命令行:
# extract text docx2txt file.docx # extract text and images docx2txt -i /tmp/img_dir file.docx
- 来自python:
importdocxpyfile='file.docx'# extract texttext=docxpy.process(file)# extract text and write images in /tmp/img_dirtext=docxpy.process(file,"/tmp/img_dir")# if you want the hyperlinksdoc=docxpy.DOCReader(file)doc.process()# process filehyperlinks=doc.data['links']