建立在this solution上:
from docx import Document
from docx.opc.constants import RELATIONSHIP_TYPE as RT
document = Document('test.docx')
rels = document.part.rels
def iter_hyperlink_rels(rels):
for rel in rels:
if rels[rel].reltype == RT.HYPERLINK:
yield rels[rel]._target
print(iter_hyperlink_rels(rels)
我需要获取超链接的url和文本(例如,url的mydomain.com
,文本的Go to My Domain
)
为了回答我自己的问题,我不得不通过
html
来完成:docx
文件html
的Foor转换:how to convert .docx file to html using python?
相关问题 更多 >
编程相关推荐