Python通过解析html来实现简历系统
发布日期:2021-05-07 21:44:12 浏览次数:23 分类:精选文章

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

第一个文件jianli.html

个人简历

姓名 wang 性别 民族 汉族

身高 167cm 职位 班长 政治面貌 团员
学制 5 学历 本科 毕业时间 2018.07
户籍 江苏省 出生年月 96.0521
专业 szmt 毕业学校 nylgp 就业范围 wddds
外语水平 四级 计算机水平 二级
奖励情况 sedd
sdd
通讯地址 qwwe 联系电话 12345678901
E-mail 2811810928@qq.com 邮编 477200  
教育经历
1
2
3
4
日期 18-06-11

 

第二个jianli1.html文件

个人简历

姓名 zhao 性别 民族 汉族

身高 164cm 职位 学生 政治面貌 团员
学制 5 学历 本科 毕业时间 2018.07
户籍 河南省鹿邑县 出生年月 94.0521
专业 szmt 毕业学校 nylgp 就业范围 wddds
外语水平 四级 计算机水平 二级
奖励情况 sedd
sdd
通讯地址 qwwe 联系电话 12345123556
E-mail 2811810928@qq.com 邮编 477200  
教育经历
1
2
3
4
日期 18-06-19

 

第三个简历.html文件

个人简历

姓名 王力宏 性别 民族 汉族

身高 174cm 职位 学委 政治面貌 党员
学制 4 学历 本科 毕业时间 2011.07
户籍 湖北 出生年月 91.0521
专业 软件 毕业学校 北京大学 就业范围 wddds
外语水平 四级 计算机水平 二级
奖励情况 sedd
sdd
通讯地址 qwwe 联系电话 12345678901
E-mail 2811810928@qq.com 邮编 477200  
教育经历
1
2
3
4
日期 14-06-11

 

把以上三个文件放到personData目录下即可。

Admin.pyw

# coding: utf-8 from PyQt4.QtGui import *from PyQt4.QtCore import *import os,sys,time,jsonimport lxml.htmlreload(sys)sys.setdefaultencoding("utf-8")class mat(QDialog):    def __init__(self):        super(mat, self).__init__()        self.initUI()    def initUI(self):        self.setWindowTitle(u"客户端")        self.setWindowFlags(Qt.Window)        self.ListHtml=getHtml()        self.setWindowTitle(u"管理端")        self.setWindowFlags(Qt.Window)        labelTime=QLabel(u"日期:")        labelNmae=QLabel(u"姓名:")        labelContent=QLabel(u"职务:")        htmlName=QLabel(u'姓名')        self.editName=QLineEdit()        htmlSex=QLabel(u'性别')        self.editSex=QLineEdit()        htmlMinzu=QLabel(u'民族')        self.editMinzu=QLineEdit()        htmlHeight=QLabel(u'身高')        self.editHeight=QLineEdit()        htmlZhiwei=QLabel(u'职务')        self.editZhiwei=QLineEdit()        htmlMianmao=QLabel(u'面貌')        self.editMianmao=QLineEdit()        htmlXuezhi=QLabel(u'学制')        self.editXuezhi=QLineEdit()        htmlXueli=QLabel(u'学历')        self.editXueli=QLineEdit()        htmlEndtime=QLabel(u'毕业时间')        self.editEndtime=QLineEdit()        htmlHuji=QLabel(u'户籍')        self.editHuji=QLineEdit()        htmlBirdate=QLabel(u'出生日期')        self.editBirdate=QLineEdit()        htmlZhuangye=QLabel(u'专业')        self.editZhuangye=QLineEdit()        htmlSchool=QLabel(u'毕业学校')        self.editSchool=QLineEdit()        htmlAddress=QLabel(u'通信地址')        self.editAddress=QLineEdit()        htmlPhone=QLabel(u'联系电话')        self.editPhone=QLineEdit()        htmlEmail=QLabel(u'E-mail  ')        self.editEmail=QLineEdit()        htmlYoubian=QLabel(u'  邮编  ')        self.editYoubian=QLineEdit()        self.timeEdit=QComboBox()        self.nameEdit=QComboBox()        self.contentEdit=QComboBox()        self.dataRead()        lay1=QHBoxLayout()        lay1.addWidget(labelTime)        lay1.addWidget(self.timeEdit)        lay2=QHBoxLayout()        lay2.addWidget(labelNmae)        lay2.addWidget(self.nameEdit)        lay3=QHBoxLayout()        lay3.addWidget(labelContent)        lay3.addWidget(self.contentEdit)        Layout=QVBoxLayout()        Layout.addLayout(lay1)        Layout.addLayout(lay2)        Layout.addLayout(lay3)        lat1=QHBoxLayout()        lat1.addWidget(htmlName)        lat1.addWidget(self.editName)        lat1.addWidget(htmlSex)        lat1.addWidget(self.editSex)        lat1.addWidget(htmlMinzu)        lat1.addWidget(self.editMinzu)        lat2=QHBoxLayout()        lat2.addWidget(htmlHeight)        lat2.addWidget(self.editHeight)        lat2.addWidget(htmlZhiwei)        lat2.addWidget(self.editZhiwei)        lat2.addWidget(htmlMianmao)        lat2.addWidget(self.editMianmao)        lat3=QHBoxLayout(htmlXuezhi)        lat3.addWidget(self.editXuezhi)        lat3.addWidget(self.editXuezhi)        lat3.addWidget(htmlXueli)        lat3.addWidget(self.editXueli)        lat3.addWidget(htmlEndtime)        lat3.addWidget(self.editEndtime)        lat4=QHBoxLayout()        lat4.addWidget(htmlHuji)        lat4.addWidget(self.editHuji)        lat4.addWidget(htmlBirdate)        lat4.addWidget(self.editBirdate)        lat5=QHBoxLayout()        lat5.addWidget(htmlZhuangye)        lat5.addWidget(self.editZhuangye)        lat5.addWidget(htmlSchool)        lat5.addWidget(self.editSchool)        lat6=QHBoxLayout()        lat6.addWidget(htmlAddress)        lat6.addWidget(self.editAddress)        lat6.addWidget(htmlPhone)        lat6.addWidget(self.editPhone)        lat7=QHBoxLayout()        lat7.addWidget(htmlEmail)        lat7.addWidget(self.editEmail)        lat7.addWidget(htmlYoubian)        lat7.addWidget(self.editYoubian)        layout=QVBoxLayout()        layout.addLayout(lat1)        layout.addLayout(lat2)        layout.addLayout(lat3)        layout.addLayout(lat4)        layout.addLayout(lat5)        layout.addLayout(lat6)        layout.addLayout(lat7)        mainLayout=QHBoxLayout(self)        mainLayout.addLayout(Layout)        mainLayout.addLayout(layout)        self.setLayout(mainLayout)        self.timeEdit.currentIndexChanged.connect(self.pro_re)        self.nameEdit.currentIndexChanged.connect(self.pro1_re)        self.contentEdit.currentIndexChanged.connect(self.pro2_re)        self.resize(650,450)    def dataRead(self):        dict_all = self.ListHtml        for id in dict_all:            self.timeEdit.addItem(id[-1][-1])            self.nameEdit.addItem(id[0][1])            self.contentEdit.addItem(id[1][3])    def pro_re(self):        index=self.timeEdit.currentIndex()        self.nameEdit.setCurrentIndex(index)        self.contentEdit.setCurrentIndex(index)        getName=str(self.nameEdit.currentText())        getTime=str(self.timeEdit.currentText())        getContent=str(self.contentEdit.currentText())        dict_all = self.ListHtml        for id in dict_all:            if id[0][1]==getName and id[-1][-1]==getTime and id[1][3]==getContent:                self.editName.setText(id[0][1])                self.editSex.setText(id[0][3])                self.editMinzu.setText(id[0][5])                self.editHeight.setText(id[1][1])                self.editZhiwei.setText(id[1][3])                self.editMianmao.setText(id[1][5])                self.editHuji.setText(id[3][1])                self.editBirdate.setText(id[3][3])                self.editZhuangye.setText(id[4][1])                self.editSchool.setText(id[4][3])                self.editAddress.setText(id[7][1])                self.editPhone.setText(id[7][3])                self.editEmail.setText(id[8][1])                self.editYoubian.setText(id[8][3])    def pro1_re(self):        index=self.nameEdit.currentIndex()        self.timeEdit.setCurrentIndex(index)        self.contentEdit.setCurrentIndex(index)        getName=str(self.nameEdit.currentText())        getTime=str(self.timeEdit.currentText())        getContent=str(self.contentEdit.currentText())        dict_all = self.ListHtml        for id in dict_all:            if id[0][1]==getName and id[-1][-1]==getTime and id[1][3]==getContent:                self.editName.setText(id[0][1])                self.editSex.setText(id[0][3])                self.editMinzu.setText(id[0][5])                self.editHeight.setText(id[1][1])                self.editZhiwei.setText(id[1][3])                self.editMianmao.setText(id[1][5])                self.editHuji.setText(id[3][1])                self.editBirdate.setText(id[3][3])                self.editZhuangye.setText(id[4][1])                self.editSchool.setText(id[4][3])                self.editAddress.setText(id[7][1])                self.editPhone.setText(id[7][3])                self.editEmail.setText(id[8][1])                self.editYoubian.setText(id[8][3])    def pro2_re(self):        index=self.contentEdit.currentIndex()        self.nameEdit.setCurrentIndex(index)        self.timeEdit.setCurrentIndex(index)        getName=str(self.nameEdit.currentText())        getTime=str(self.timeEdit.currentText())        getContent=str(self.contentEdit.currentText())        dict_all = self.ListHtml        for id in dict_all:            if id[0][1]==getName and id[-1][-1]==getTime and id[1][3]==getContent:                self.editName.setText(id[0][1])                self.editSex.setText(id[0][3])                self.editMinzu.setText(id[0][5])                self.editHeight.setText(id[1][1])                self.editZhiwei.setText(id[1][3])                self.editMianmao.setText(id[1][5])                self.editHuji.setText(id[3][1])                self.editBirdate.setText(id[3][3])                self.editZhuangye.setText(id[4][1])                self.editSchool.setText(id[4][3])                self.editAddress.setText(id[7][1])                self.editPhone.setText(id[7][3])                self.editEmail.setText(id[8][1])                self.editYoubian.setText(id[8][3])def getHtml():    upDid= os.path.abspath(os.path.join(os.path.dirname(__file__),"."))    htmlDid=upDid+"\\personData"    getdir=os.listdir(htmlDid)    #print getdir    listHtml=[]    for id in getdir:        if id.split('.')[-1]=="html":            importPath=htmlDid+"\\"+id            doc = lxml.html.parse(importPath)            a=[[j for j in i.xpath('td/a[not(contains(.,"spam"))]/@href | td[not(a)]/text()')] for i in doc.xpath('//tr')]            listHtml.append(a)    return (listHtml)def main():    app = QApplication(sys.argv)    ex = mat()    ex.show()    app.exec_()if __name__ == '__main__':    main()

这里写图片描述

这里写图片描述

这里写图片描述

这里写图片描述

admin.py会自动遍历personData目录下的html文件,并捕获信息,设置到界面上。

如果想要添加模板,打开html修改信息另存即可,名字随意。
运行admin.py下次就回把模板的信息设置到界面上。
moban

简历

个人简历

姓名 性别 民族

身高 职位 学生 政治面貌
学制 学历 本科 毕业时间
户籍 出生年月
专业 毕业学校 就业范围
外语水平 四级 计算机水平
奖励情况
通讯地址 联系电话
E-mail 邮编  
教育经历
日期

 

上一篇:Maya根据模型建立乐高模型
下一篇:python logging 日志 通过修饰器获取错误信息

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2025年03月22日 06时16分49秒