文章目录
0 前言
🔥这两年开始毕业设计和毕业答辩的要求和难度不断提升,传统的毕设题目缺少创新和亮点,往往达不到毕业答辩的要求,这两年不断有学弟学妹告诉学长自己做的项目系统达不到老师的要求。
为了大家能够顺利以及最少的精力通过毕设,学长分享优质毕业设计项目,今天要分享的是
🚩 毕业设计 大数据招聘租房可视化系统(源码+论文)
🥇学长这里给一个题目综合评分(每项满分5分)
难度系数:3分
工作量:3分
创新点:4分
🧿 项目分享:见文末!
1 项目运行效果
视频效果:
毕业设计 大数据招聘租房可视化系统
2 课题项目介绍
学长设计的本项目利用 python 网络爬虫抓取常见招聘网站和租房网站的租房信息,完成数据清洗和结构化,存储到数据库中,搭建web系统对招聘信息的薪资、待遇和租房的地区、朝向、价格影响因素进行统计分析并可视化展示。
3 相关技术介绍
3.1 爬虫
网络爬虫是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本。爬虫对某一站点访问,如果可以访问就下载其中的网页内容,并且通过爬虫解析模块解析得到的网页链接,把这些链接作为之后的抓取目标,并且在整个过程中完全不依赖用户,自动运行。若不能访问则根据爬虫预先设定的策略进行下一个 URL的访问。在整个过程中爬虫会自动进行异步处理数据请求,返回网页的抓取数据。在整个的爬虫运行之前,用户都可以自定义的添加代理,伪 装 请求头以便更好地获取网页数据。爬虫流程图如下:
3.2 Ajax技术
Ajax 是一种独立于 Web 服务器软件的浏览器技术。
Ajax使用 JavaScript 向服务器提出请求并处理响应而不阻塞的用户核心对象XMLHttpRequest。通过这个对象,您的 JavaScript 可在不重载页面的情况与 Web 服务器交换数据,即在不需要刷新页面的情况下,就可以产生局部刷新的效果。
前端将需要的参数转化为JSON字符串,再通过get/post方式向服务器发送一个请并将参数直接传递给后台,后台对前端请求做出反应,接收数据,将数据作为条件查询,但会j’son字符串格式的查询结果集给前端,前端接收到后台返回的数据进行条件判断并作出相应的页面展示。
$.ajax({
url:'http://127.0.0.1:5000/updatePass',
type:"POST",
data:JSON.stringify(data.field),
contentType:"application/json; charset=utf-8",
dataType:"json",success:function(res){if(res.code ==200){
layer.msg(res.msg,{icon:1});}else{
layer.msg(res.msg,{icon:2});}}})
3.3 Echarts
ECharts(Enterprise Charts)是百度开源的数据可视化工具,底层依赖轻量级Canvas库ZRender。兼容了几乎全部常用浏览器的特点,使它可广泛用于PC客户端和手机客户端。ECharts能辅助开发者整合用户数据,创新性的完成个性化设置可视化图表。支持折线图(区域图)、柱状图(条状图)、散点图(气泡图)、K线图、饼图(环形图)等,通过导入 js 库在 Java Web 项目上运行。
4 数据获取
我们利用 python 的 request + beautifulsoup 从某拉勾网和链家等平台抓取了九个城市的招聘和租房数据。
4.1 总体流程如下
4.2 获取招聘数据
因为拉勾网具有较强的反爬机制,使用user-agent和cookies封装头部信息,将爬虫程序伪装成浏览器访问网页,通过request包post方法进行url请求,请求成功返回json格式字符串,并使用字典方法直接读取数据,即可拿到我们想要的python职位相关的信息,可以通过读取总职位数,通过总的职位数和每页能显示的职位数,我们可以计算出总共有多少页,然后使用循环按页爬取,最后将职位信息汇总,写入到CSV格式的文件以及本地的mysql数据库中。
import requests
import math
import time
import pandas as pd
import pymysql
from sqlalchemy import create_engine
defget_json(url, num):"""
从指定的url中通过requests请求携带请求头和请求体获取网页中的信息,
:return:
"""
url1 ='https://www.lagou.com/jobs/list_python/p-city_0?&cl=false&fromSearch=true&labelWords=&suginput='
headers ={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36','Host':'www.lagou.com','Referer':'https://www.lagou.com/jobs/list_%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90?labelWords=&fromSearch=true&suginput=','X-Anit-Forge-Code':'0','X-Anit-Forge-Token':'None','X-Requested-With':'XMLHttpRequest','Cookie':'user_trace_token=20210218203227-35e936a1-f40f-410d-8400-b87f9fb4be0f; _ga=GA1.2.331665492.1613651550; LGUID=20210218203230-39948353-de3f-4545-aa01-43d147708c69; LG_HAS_LOGIN=1; hasDeliver=0; privacyPolicyPopup=false; showExpriedIndex=1; showExpriedCompanyHome=1; showExpriedMyPublish=1; RECOMMEND_TIP=true; index_location_city=%E5%85%A8%E5%9B%BD; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1613651550,1613652253,1613806244,1614497914; _putrc=52ABCFBE36E5D0BD123F89F2B170EADC; gate_login_token=ea312e017beac7fe72547a32956420b07d6d5b1816bc766035dd0f325ba92b91; JSESSIONID=ABAAAECAAEBABII8D8278DB16CB050FD656DD1816247B43; login=true; unick=%E7%94%A8%E6%88%B72933; WEBTJ-ID=20210228%E4%B8%8B%E5%8D%883:38:37153837-177e7932b7f618-05a12d1b3d5e8c-53e356a-1296000-177e7932b8071; sensorsdata2015session=%7B%7D; _gid=GA1.2.1359196614.1614497918; __lg_stoken__=bb184dd5d959320e9e61d943e802ac98a8538d44699751621e807e93fe0ffea4c1a57e923c71c93a13c90e5abda7a51873c2e488a4b9d76e67e0533fe9e14020734016c0dcf2; X_MIDDLE_TOKEN=90b85c3630b92280c3ad7a96c881482e; LGSID=20210228161834-659d6267-94a3-4a5c-9857-aaea0d5ae2ed; TG-TRACK-CODE=index_navigation; SEARCH_ID=092c1fd19be24d7cafb501684c482047; X_HTTP_TOKEN=fdb10b04b25b767756070541617f658231fd72d78b; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2220600756%22%2C%22first_id%22%3A%22177b521c02a552-08c4a0f886d188-73e356b-1296000-177b521c02b467%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24os%22%3A%22Linux%22%2C%22%24browser%22%3A%22Chrome%22%2C%22%24browser_version%22%3A%2288.0.4324.190%22%2C%22lagou_company_id%22%3A%22%22%7D%2C%22%24device_id%22%3A%22177b521c02a552-08c4a0f886d188-73e356b-1296000-177b521c02b467%22%7D; _gat=1; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1614507066; LGRID=20210228181106-f2d71d85-74fe-4b43-b87e-d78a33c872ad'}
data ={'first':'true','pn': num,'kd':'BI工程师'}#得到Cookies信息
s = requests.Session()print('建立session:', s,'\n\n')
s.get(url=url1, headers=headers, timeout=3)
cookie = s.cookies
print('获取cookie:', cookie,'\n\n')#添加请求参数以及headers、Cookies等信息进行url请求
res = requests.post(url, headers=headers, data=data, cookies=cookie, timeout=3)
res.raise_for_status()
res.encoding ='utf-8'
page_data = res.json()print('请求响应结果:', page_data,'\n\n')return page_data
defget_page_num(count):"""
计算要抓取的页数,通过在拉勾网输入关键字信息,可以发现最多显示30页信息,每页最多显示15个职位信息
:return:
"""
page_num = math.ceil(count /15)if page_num >29:return29else:return page_num
defget_page_info(jobs_list):"""
获取职位
:param jobs_list:
:return:
"""
page_info_list =[]for i in jobs_list:# 循环每一页所有职位信息
job_info =[]
job_info.append(i['companyFullName'])
job_info.append(i['companyShortName'])
job_info.append(i['companySize'])
job_info.append(i['financeStage'])
job_info.append(i['district'])
job_info.append(i['positionName'])
job_info.append(i['workYear'])
job_info.append(i['education'])
job_info.append(i['salary'])
job_info.append(i['positionAdvantage'])
job_info.append(i['industryField'])
job_info.append(i['firstType'])
job_info.append(",".join(i['companyLabelList']))
job_info.append(i['secondType'])
job_info.append(i['city'])
page_info_list.append(job_info)return page_info_list
defunique(old_list):
newList =[]for x in old_list:if x notin newList :
newList.append(x)return newList
defmain():
connect_info ='mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8'.format("root","123456","localhost","3306","20_lagou")
engine = create_engine(connect_info)
url =' https://www.lagou.com/jobs/positionAjax.json?needAddtionalResult=false'
first_page = get_json(url,1)
total_page_count = first_page['content']['positionResult']['totalCount']
num = get_page_num(total_page_count)
total_info =[]
time.sleep(10)for num inrange(1, num +1):# 获取每一页的职位相关的信息
page_data = get_json(url, num)# 获取响应json
jobs_list = page_data['content']['positionResult']['result']# 获取每页的所有python相关的职位信息
page_info = get_page_info(jobs_list)
total_info += page_info
print('已经爬取到第{}页,职位总数为{}'.format(num,len(total_info)))
time.sleep(20)#将总数据转化为data frame再输出,然后在写入到csv格式的文件中以及本地数据库中
df = pd.DataFrame(data=unique(total_info),
columns=['companyFullName','companyShortName','companySize','financeStage','district','positionName','workYear','education','salary','positionAdvantage','industryField','firstType','companyLabelList','secondType','city'])
df.to_csv('bi.csv', index=True)print('职位信息已保存本地')
df.to_sql(name='demo', con=engine, if_exists='append', index=False)print('职位信息已保存数据库')
4.3 获取租房房源信息
import requests
from pyquery import PyQuery as pq
from fake_useragent import UserAgent
import time
import pandas as pd
import random
import pymysql
from sqlalchemy import create_engine
UA = UserAgent()
headers ={'Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','Cookie':'lianjia_uuid=6383a9ce-19b9-47af-82fb-e8ec386eb872; UM_distinctid=1777521dc541e1-09601796872657-53e3566-13c680-1777521dc5547a; _smt_uid=601dfc61.4fcfbc4b; _ga=GA1.2.894053512.1612577894; _jzqc=1; _jzqckmp=1; _gid=GA1.2.1480435812.1614959594; Hm_lvt_9152f8221cb6243a53c83b956842be8a=1614049202,1614959743; csrfSecret=lqKM3_19PiKkYOfJSv6ldr_c; activity_ke_com=undefined; ljisid=6383a9ce-19b9-47af-82fb-e8ec386eb872; select_nation=1; crosSdkDT2019DeviceId=-kkiavn-2dq4ie-j9ekagryvmo7rd3-qjvjm0hxo; Hm_lpvt_9152f8221cb6243a53c83b956842be8a=1615004691; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%221777521e37421a-0e1d8d530671de-53e3566-1296000-1777521e375321%22%2C%22%24device_id%22%3A%221777521e37421a-0e1d8d530671de-53e3566-1296000-1777521e375321%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.baidu.com%2Flink%22%2C%22%24latest_referrer_host%22%3A%22www.baidu.com%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_utm_source%22%3A%22guanwang%22%2C%22%24latest_utm_medium%22%3A%22pinzhuan%22%2C%22%24latest_utm_campaign%22%3A%22wybeijing%22%2C%22%24latest_utm_content%22%3A%22biaotimiaoshu%22%2C%22%24latest_utm_term%22%3A%22biaoti%22%7D%7D; lianjia_ssid=7a179929-0f9a-40a4-9537-d1ddc5164864; _jzqa=1.3310829580005876700.1612577889.1615003848.1615013370.6; _jzqy=1.1612577889.1615013370.2.jzqsr=baidu|jzqct=%E9%93%BE%E5%AE%B6.jzqsr=baidu; select_city=440300; srcid=eyJ0Ijoie1wiZGF0YVwiOlwiZjdiNTI1Yjk4YjI3MGNhNjRjMGMzOWZkNDc4NjE4MWJkZjVjNTZiMWYxYTM4ZTJkNzMxN2I0Njc1MDEyY2FiOWMzNTIzZTE1ZjEyZTE3NjlkNTRkMTA2MWExZmIzMWM5YzQ3ZmQxM2M3NTM5YTQ1YzM5OWU0N2IyMmFjM2ZhZmExOGU3ZTc1YWU0NDQ4NTdjY2RiMjEwNTQyMDQzM2JiM2UxZDQwZWQwNzZjMWQ4OTRlMGRkNzdmYjExZDQwZTExNTg5NTFkODIxNWQzMzdmZTA4YmYyOTFhNWQ2OWQ1OWM4ZmFlNjc0OTQzYjA3NDBjNjNlNDYyNTZiOWNhZmM4ZDZlMDdhNzdlMTY1NmM0ZmM4ZGI4ZGNlZjg2OTE2MmU4M2MwYThhNTljMGNkODYxYjliNGYwNGM0NzJhNGM3MmVmZDUwMTJmNmEwZWMwZjBhMzBjNWE2OWFjNzEzMzM4M1wiLFwia2V5X2lkXCI6XCIxXCIsXCJzaWduXCI6XCJhYWEyMjhiNVwifSIsInIiOiJodHRwczovL20ubGlhbmppYS5jb20vY2h1enUvc3ovenVmYW5nL3BnJTdCJTdELyIsIm9zIjoid2ViIiwidiI6IjAuMSJ9','Host':'sz.lianjia.com','Referer':'https://sz.lianjia.com/zufang/','User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36',}
num_page =2classLianjia_Crawer:def__init__(self, txt_path):super(Lianjia_Crawer, self).__init__()
self.file=str(txt_path)
self.df = pd.DataFrame(
columns=['title','district','area','orient','floor','price','city'])defrun(self):'''启动脚本'''
connect_info ='mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8'.format("root","123456","localhost","3366","lagou")
engine = create_engine(connect_info)for i inrange(100):
url ="https://sz.lianjia.com/zufang/pg{}/".format(str(i))
self.parse_url(url)
time.sleep(random.randint(2,5))print('正在爬取的 url 为 {}'.format(url))print('爬取完毕!!!!!!!!!!!!!!')
self.df.to_csv(self.file, encoding='utf-8')print('租房信息已保存至本地')
self.df.to_sql(name='house', con=engine,
if_exists='append', index=False)print('租房信息已保存数据库')defparse_url(self, url):
headers['User-Agent']= UA.chrome
res = requests.get(url, headers=headers)# 声明pq对象
doc = pq(res.text)for i in doc('.content__list--item .content__list--item--main'):try:
pq_i = pq(i)# 房屋标题
title = pq_i('.content__list--item--title a').text()# 具体信息
houseinfo = pq_i('.content__list--item--des').text()# 行政区
address =str(houseinfo).split('/')[0]
district =str(address).split('-')[0]# 房屋面积
full_area =str(houseinfo).split('/')[1]
area =str(full_area)[:-1]# 朝向
orient =str(houseinfo).split('/')[2]# 楼层
floor =str(houseinfo).split('/')[-1]# 价格
price = pq_i('.content__list--item-price').text()# 城市
city ='深圳'
data_dict ={'title': title,'district': district,'area': area,'orient': orient,'floor': floor,'price': price,'city': city}
self.df = self.df.append(data_dict, ignore_index=True)print([title, district, area, orient, floor, price, city])except Exception as e:print(e)print("索引提取失败,请重试!!!!!!!!!!!!!")if __name__ =="__main__":# txt_path = "zufang_shenzhen.csv"
txt_path ="test.csv"
Crawer = Lianjia_Crawer(txt_path)
Crawer.run()# 启动爬虫脚本
爬取过程
将爬取到的数据写入到CSV格式的文件以及本地的mysql数据库中
其中数据库建三张表分别保存用户、租房、招聘信息数据
连接数据库操作
connect_info ='mysql+pymysql://{}:{}@{}:{}/{}?charset=utf8'.format("root","123456","localhost","3306","my_db")
engine = create_engine(connect_info)
5 数据可视化
使用echarts可视化展示
创建如下目录结构:
js 目录中为 echarts的 js 文件,大家可以在 echarts官网下载自己需要的版本,index.html 文件内容如下
#部分代码
!DOCTYPE html>
<html><head><metacharset="utf-8"/><metahttp-equiv="X-UA-Compatible"content="IE=edge,chrome=1"><metaname="viewport"content="width=device-width, initial-scale=1, maximum-scale=1"><linkhref="./assets/images/logo.png"rel="icon"><title>毕业生の招聘+租房数据可视化系统</title><linkrel="stylesheet"href="./assets/libs/layui/css/layui.css"/><linkrel="stylesheet"href="./assets/module/admin.css?v=315"/><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--></head><bodyclass="layui-layout-body"><divclass="layui-layout layui-layout-admin"><!-- 头部 --><divclass="layui-header"><divclass="layui-logo"><imgsrc="./assets/images/logo.png"/><cite> 毕业生の数据可视化</cite></div><ulclass="layui-nav layui-layout-left"><liclass="layui-nav-item"lay-unselect><aew-event="flexible"title="侧边伸缩"><iclass="layui-icon layui-icon-shrink-right"></i></a></li><liclass="layui-nav-item"lay-unselect><aew-event="refresh"title="刷新"><iclass="layui-icon layui-icon-refresh-3"></i></a></li></ul><ulclass="layui-nav layui-layout-right"><liclass="layui-nav-item"lay-unselect><aew-event="message"title="消息"><iclass="layui-icon layui-icon-notice"></i><spanclass="layui-badge-dot"></span></a></li><liclass="layui-nav-item"lay-unselect><aew-event="note"title="便签"><iclass="layui-icon layui-icon-note"></i></a></li><liclass="layui-nav-item layui-hide-xs"lay-unselect><aew-event="fullScreen"title="全屏"><iclass="layui-icon layui-icon-screen-full"></i></a></li><liclass="layui-nav-item layui-hide-xs"lay-unselect><aew-event="lockScreen"title="锁屏"><iclass="layui-icon layui-icon-password"></i></a></li><liclass="layui-nav-item"lay-unselect><a><imgsrc="assets/images/head.png"class="layui-nav-img"><cite>zz</cite></a><dlclass="layui-nav-child"><ddlay-unselect><aew-href="page/template/user-info.html">个人中心</a></dd><ddlay-unselect><aew-event="psw">修改密码</a></dd><hr><ddlay-unselect><aew-event="logout"data-url="page/template/login.html">退出</a></dd></dl></li><liclass="layui-nav-item"lay-unselect><aew-event="theme"title="主题"><iclass="layui-icon layui-icon-more-vertical"></i></a></li></ul></div>
6 实现效果
6.1 招聘数据和租房数据概况
可根据学习和职位进行筛选查询
6.2 个人中心
可修改基本信息,密码等
6.3 招聘信息可视化
6.4 招聘信息城市之间对比图
6.5 租房数据可视化
6.6 薪资预测
篇幅有限,更多详细设计见设计论文
7 最后
项目包含内容
一万七千字 完整详细设计论文
🧿 项目分享:见文末!
版权归原作者 Fiercely 所有, 如有侵权,请联系我们删除。