在一些常规分析过程中,常会判断这个文档是否为拷贝检测,对WORD而言,其内部数据中封装了相关的属性信息,如在WINDOW环境下,通过右键属性可以看到其相关的信息如下:
那么如何用程序来自动实现这些信息的自动提取呢。
主要有两种方法:
一是每个WORD文档实际上就是一个压缩包,这些信息是放在压缩包中的core.xml的文件里面的。通过读取这个文件,即可以获得上述信息;
二是直接利用python-docx来进行WORD的操作,实现对这些信息的提取。
其简单的代码块如下:
def get_wordinfo(document):
core_properties = document.core_properties
print('作者:', core_properties.author)
print('创建时间', core_properties.created)
print(core_properties.last_modified_by)
print(core_properties.last_printed)
print(core_properties.modified)
print(core_properties.revision)
print(core_properties.title)
print(core_properties.category)
print(core_properties.comments)
print(core_properties.identifier)
print(core_properties.keywords)
print(core_properties.language)
print(core_properties.subject)
print(core_properties.version)
print(core_properties.keywords)
print(core_properties.content_status)
return {'作者':core_properties.author,'创建时间':core_properties.created.value,'修改人':core_properties.last_modified_by,
'最后打印时间':core_properties.last_printed.value,'最后修改时间':core_properties.modified.value}
其效果如下所示:
{'作者': 'Administrator', '创建时间': '2018-08-24 03:41:00', '修改人': '778514434@qq.com', '最后打印时间': '2018-10-15 05:57:00', '最后修改时间': '2020-06-20 01:58:00'}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有