博客
关于我
一个薪资double的捷径:自动化简历内推工具
阅读量:557 次
发布时间:2019-03-09

本文共 4955 字,大约阅读时间需要 16 分钟。

最近,小编在处理简历时,发现大量简历需要一个个打开文件,复制姓名、邮箱、电话号码、学历等关键信息,效率特别低且部分文件无法直接复制。于是,小编便写了文件阅读工具的脚本,支持文件格式有:doc,docx,pdf

通过脚本自动匹配各种简历的文件格式,并解析出用户名、邮箱、电话号码、学历等关键信息。然后调用企业微信,使用正则过滤简历,使用request一键内推到企微。

ps. 上月战绩,内推400+人,内推成功8人,入职5人,收米8000*2+5000*3=31000。

{'感谢您的投递': 331, '简历处理中': 19, '简历初筛': 5, '本轮通过': 6, 'Offer已发放': 1, '进行中': 2, '拒绝Offer': 3, '接受Offer': 5} 

 

脚本功能:提取简历文本

输入:要解析的文件路径

输出:解析的内容,包括不限于姓名、邮箱、电话号码、学历等信息。

环境:python 3.6 、mac(doc转docx是mac写法,windows更简单,导入win32的包即可)

 

第一步:需要导入的包

# encoding: utf-8import os, sysimport docxfrom pdfminer.pdfparser import PDFParserfrom pdfminer.pdfdocument import PDFDocumentfrom pdfminer.pdfpage import PDFPagefrom pdfminer.pdfinterp import PDFResourceManagerfrom pdfminer.pdfinterp import PDFPageInterpreterfrom pdfminer.layout import LAParamsfrom pdfminer.converter import PDFPageAggregator

第二步:读文件

def get_files(path):    res = []    for i in os.listdir(path):        # 去掉临时文件        if os.path.isfile(path+i) and '~$' not in i and '.DS' not in i:            # 去重 1.doc 和 1.docx            if (path+i).split(".")[0] not in str(res):                res.append(path+i)    return res

第三步:读PDF,得到res文本后,可以通过正则,匹配出邮箱,手机号,学历等

def pdf_reader(file):    fp = open(file, "rb")    # 创建一个与文档相关联的解释器    parser = PDFParser(fp)    # PDF文档对象    doc = PDFDocument(parser)    # 链接解释器和文档对象    parser.set_document(doc)    # doc.set_paeser(parser)    # 初始化文档    # doc.initialize("")    # 创建PDF资源管理器    resource = PDFResourceManager()    # 参数分析器    laparam = LAParams()    # 创建一个聚合器    device = PDFPageAggregator(resource, laparams=laparam)    # 创建PDF页面解释器    interpreter = PDFPageInterpreter(resource, device)    # 使用文档对象得到页面集合    res = ''    for page in PDFPage.create_pages(doc):        # 使用页面解释器来读取        interpreter.process_page(page)        # 使用聚合器来获取内容        layout = device.get_result()        for out in layout:            if hasattr(out, "get_text"):                res = res + '' + out.get_text()    return res

第四步:读word格式文件。待优化:word中如果包含execl,暂时读不出来。

def word_reader(file):    try:        # docx 直接读        if 'docx' in file:            res = ''            f = docx.Document(file)            for para in f.paragraphs:                res = res + '\n' +para.text        else:            # 先转格式doc>docx            os.system("textutil -convert docx '%s'"%file)            word_reader(file+'x')            res = ''            f = docx.Document(file+'x')            for para in f.paragraphs:                res = res + '\n' +para.text        return res    except:        # print(file, 'read failed')        return ''

完整代码

# encoding: utf-8import os, sysimport docxfrom pdfminer.pdfparser import PDFParserfrom pdfminer.pdfdocument import PDFDocumentfrom pdfminer.pdfpage import PDFPagefrom pdfminer.pdfinterp import PDFResourceManagerfrom pdfminer.pdfinterp import PDFPageInterpreterfrom pdfminer.layout import LAParamsfrom pdfminer.converter import PDFPageAggregatordef get_files(path):    res = []    for i in os.listdir(path):        # 去掉临时文件        if os.path.isfile(path+i) and '~$' not in i and '.DS' not in i:            # 去重 1.doc 和 1.docx            if (path+i).split(".")[0] not in str(res):                res.append(path+i)    return resdef pdf_reader(file):    fp = open(file, "rb")    # 创建一个与文档相关联的解释器    parser = PDFParser(fp)    # PDF文档对象    doc = PDFDocument(parser)    # 链接解释器和文档对象    parser.set_document(doc)    # doc.set_paeser(parser)    # 初始化文档    # doc.initialize("")    # 创建PDF资源管理器    resource = PDFResourceManager()    # 参数分析器    laparam = LAParams()    # 创建一个聚合器    device = PDFPageAggregator(resource, laparams=laparam)    # 创建PDF页面解释器    interpreter = PDFPageInterpreter(resource, device)    # 使用文档对象得到页面集合    res = ''    for page in PDFPage.create_pages(doc):        # 使用页面解释器来读取        interpreter.process_page(page)        # 使用聚合器来获取内容        layout = device.get_result()        for out in layout:            if hasattr(out, "get_text"):                res = res + '' + out.get_text()    return resdef word_reader(file):    try:        # docx 直接读        if 'docx' in file:            res = ''            f = docx.Document(file)            for para in f.paragraphs:                res = res + '\n' +para.text        else:            # 先转格式doc>docx            os.system("textutil -convert docx '%s'"%file)            word_reader(file+'x')            res = ''            f = docx.Document(file+'x')            for para in f.paragraphs:                res = res + '\n' +para.text        return res    except:        # print(file, 'read failed')        return ''def file_reader(file):    if 'doc' in file:        res = word_reader(file)    elif 'pdf' in file:        res = pdf_reader(file)    else:        res = '不是doc,也不是pdf,文件格式不支持!'    return resif __name__ == '__main__':    path = "/Users/XXXXX/Mine/XXXXX/"    abs_files = get_files(path)    print(abs_files)    for file in abs_files:        file_text = file_reader(file)        print(file_text)

本期实现:任何格式的简历,解析成文本,便于后续筛选优质简历。

下期揭晓:简历过滤,包括学历,稳定性,年龄,工龄与职级匹配度等,全自动化内推代码。

 

转载地址:http://eodpz.baihongyu.com/

你可能感兴趣的文章
MYSQL一直显示正在启动
查看>>
MySQL一站到底!华为首发MySQL进阶宝典,基础+优化+源码+架构+实战五飞
查看>>
MySQL万字总结!超详细!
查看>>
Mysql下载以及安装(新手入门,超详细)
查看>>
MySQL不会性能调优?看看这份清华架构师编写的MySQL性能优化手册吧
查看>>
MySQL不同字符集及排序规则详解:业务场景下的最佳选
查看>>
Mysql不同官方版本对比
查看>>
MySQL与Informix数据库中的同义表创建:深入解析与比较
查看>>
mysql与mem_细说 MySQL 之 MEM_ROOT
查看>>
MySQL与Oracle的数据迁移注意事项,另附转换工具链接
查看>>
mysql丢失更新问题
查看>>
MySQL两千万数据优化&迁移
查看>>
MySql中 delimiter 详解
查看>>
MYSQL中 find_in_set() 函数用法详解
查看>>
MySQL中auto_increment有什么作用?(IT枫斗者)
查看>>
MySQL中B+Tree索引原理
查看>>
mysql中cast() 和convert()的用法讲解
查看>>
mysql中datetime与timestamp类型有什么区别
查看>>
MySQL中DQL语言的执行顺序
查看>>
mysql中floor函数的作用是什么?
查看>>