python爬取简历

import zipfile
import re
from win32com import client as wc #导入模块
import os
import pymysql


#将doc转化为docx.因docx为压缩包,自带html文件
def doc_to_docx(file):
    word = wc.Dispatch("Word.Application") # 打开word应用程序
    doc = word.Documents.Open(file) #打开word文件
    doc.SaveAs("{}x".format(file), 12)#另存为后缀为".docx"的文件,其中参数12指docx文件
    doc.Close() #关闭原来word文件
    word.Quit()
    print(file.split('/')[-1]+"完成!")
    return "{}x".format(file)


def get_document(filepath):
    z = zipfile.ZipFile(filepath, "r")
    text = z.read("word/document.xml").decode("UTF-8")
    text = re.sub(r"<.*?>", "", text)#去除xml里的所有标记符
    return text



if __name__ == '__main__':
    file_path= 'C:/Users/lenovo/Desktop/other/简历/长亮数据-咨询部笔试题目-附件'
    for filename in os.listdir(file_path):
        if filename.split('.')[-1] != 'docx':
            fp = doc_to_docx(file_path+'/'+filename)
            page_text = get_document(fp)
            print(page_text)
            # 性别
            sex = re.findall(r"目前正在找工作   (.*?) | | 现居住", page_text, re.S)[0]
            if len(sex) <1:
                sex = 'null'
            # 年龄
            age = re.findall(r"现居住 .*? | (.*?)年工作经验最近工作", page_text, re.S)[0].split('|')[1]
            if len(age) <1:
                age = 'null'
            # 地址
            dress = re.findall(r"现居住 .*? | (.*?)年工作经验最近工作", page_text, re.S)[0].split('|')[2].strip().split(' ')[-1]
            if dress == '现居住':
                dress = 'null'
            # 工作年龄
            work_age = re.findall(r"现居住 .*? | (.*?)年工作经验最近工作", page_text, re.S)[0].split('|')[-1]
            if len(work_age) <1:
                work_age = 'null'
            # 职位
            work_name = re.findall(r"职 位:(.*?)公 司:行 业", page_text, re.S)[0]
            if len(work_name) <1:
                work_name = 'null'
            # 公司
            company_name = re.findall(r"公 司:(.*?)行 业", page_text, re.S)[0]
            if len(company_name) <1:
                company_name= 'null'
            # 行业
            industry_name = re.findall(r"职 位:(.*?)公 司:行 业", page_text, re.S)[0]
            if len(industry_name) <1:
                industry_name = 'null'
            # 专业
            profession_name = re.findall(r"最高学历/学位 专 业:(.*?)学 校:", page_text, re.S)[0]
            if len(profession_name) <1:
                profession_name = 'null'
            # 学校
            school_name = re.findall(r"学 校:(.*?)学历/学位", page_text, re.S)[0]
            if len(school_name) <1:
                school_name= 'null'
            # 学历
            education = re.findall(r"学历/学位:(.*?)个人信息户口/国籍", page_text, re.S)[0]
            if len(education) <1:
                education = 'null'
            print(sex, age, dress, work_age, work_name, company_name, industry_name, profession_name, school_name,
                  education)
        else:
            continue
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小徐老师_xiho

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值