🍅文末获取微信联系🍅
IT实战营是一个专注项目实战的培训机构,多名老师是csdn、51CTO的签约讲师,致力于为学生提供高质量的项目辅导。主要业务方向为Java,Python,小程序,微服务,爬虫,大数据,PHP,NodeJS,asp.net,app等项目辅导,答疑,远程安装运行!
👇🏻 精彩专栏推荐订阅👇🏻
Python毕设项目选题源代码500个
Java毕设项目选题源代码1000个
微信小程序毕设项目源代码500个
PHP毕设项目源代码500个
Node.JS毕设项目源代码500个
.NET/ASP.NET毕设项目源代码500个
更多选题,文末微信名片咨询👇🏻
目录
一、前言
该项目含有源码、文档、PPT、配套开发软件、软件安装教程、项目发布教程、包运行成功以及课程答疑与微信售后交流群、送查重系统不限次数免费查重等福利!
房价是一个国家经济水平的重要体现,也是反映居民生活质量和水平的最直接的指标。目前我国住房制度以租售并举形式出现,房屋所有权人通过出售、出租房屋获得租金收入。但是由于房价波动较大,不能及时反映房价变化趋势,需要预测房价来指导市场。研究房产价格走势,可以为房地产价格的调控提供参考依据。本系统通过对网络爬虫的分析,研究58同城网房屋数据,尝试使用Python技术进行开发,将58同城网房产信息和房屋数据尽可能的爬取出来,并对结果进行检测判断,最后可视化分析出来,为用户提供精确的查询结果。基于Python的房价预测系统旨在提高数据挖掘的效率,便于科学的管理和分析房屋数据。
本文先分析基于Python的房价预测系统的背景和意义;对常见的爬虫原理,获取策略,信息提取等技术进行分析;本系统使用python进行开发,MySQL数据库进行搭建,实现了房产的数据爬取;对数据库的查询结果进行检测并可视化分析,对系统的前台界面进行管理,分析爬取的结果,并对房价预测结果进行大屏显示;最后通过测试实现了数据爬取,存储过滤和数据可视化分析,以及系统管理等功能。
下面是资料信息截图:
二、功能介绍
数据管理功能设计
完成数据采集后,数据存储在MySQL中,基于Python的房价预测系统可以对爬取的数据进行管理,管理员登录数据库,可以查看每一条房产价格的内容以及爬取的目标网址,也可以对单条的房产价格进行删除。此外,管理还具有系统管理、用户管理等功能。前台用户具有注册登录,信息查看等功能,其中大屏数据包括房屋名称统计、价格趋势统计、房型统计、类型统计、区域统计。其中,基于Python的房价预测系统的数据管理功能模块如图4.3所示。
在系统前台,所有的用户都可以通过浏览器访问基于Python的房价预测系统,查看所有大屏数据。在系统后台,管理员对数据进行管理。
其中普通用户功能如下:
(1)登录注册
(2)查看系统简介信息。
(3)查看房屋资讯信息。
(4)房产楼盘信息查看,包括楼盘名称、价格区间、开盘日期、地址、楼盘图片。
(5)房屋信息查看,包括房屋名称、户型、楼层、小区、面积、价格等。
(6)房产信息评论(查看其他会员的评论信息,登录后发布房产评论)。
(7)对各不同的房产数据进行点赞、踩、收藏。
(8)个人中心,修改个人信息,修改个人密码。查看个人收藏的房屋数据,移除收藏。
(9)信息反馈,发布反馈信息给管理员,给出系统建设意见和建议。
系统后台的管理员功能如下:
(1)管理所有爬取的数据信息:更新房产、房屋数据信息。包括爬取的网址、房产标题、图片、名称、标签、价格、开盘日期、交房日期、户型、地址。
(2)管理用户信息:用户信息的添加,删除。
(3)管理房屋类型信息:房屋类型信息的添加,删除。
(4)管理区域信息:区域信息的添加,删除。
(5)系统管理:管理系统轮播图广告信息,自定义图片内容。
(6)数据可视化大屏:通过大屏展示所有的房屋统计、价格趋势统计、热销户型统计、热销区域等。
(7)留言反馈管理,查看会员反馈的信息,及时处理。
(8)系统简介管理,修改系统简介信息。
数据采集的实现
启动项目,运行爬虫程序,首先通过指定的URL进行过滤,然后将待抓取的URL放入抓取队列中。接着读取URL,解析DNS,下载网页内容,将文本内容通过BeautifulSoup进行存储。
其中爬取到的数据如5.1所示。
分析HTML,获取对方文本,通过BeautifulSoup. find_all方法查找a链接下的信息,样式为post-item-title。于是得到代码:
soup.find_all("a", class_="post-item-title")
可以读取到所有a链接,并且样式名称为post-item-title的内容。该内容就是本系统需要的爬取内容,包括了房屋数据的标题、URL地址和内容。再通过for语句循环爬取到的对象结果,使用MySQL的cursor.execute方法进行数据保存,最后commit提交方法把数据插入到数据库。本爬虫用到的类库如下:
import requests
import json
from bs4 import BeautifulSoup
import re
import pymysql
系统首页的实现
前台使用VUE技术进行数据查询,在首页中,先建立和服务器端连接请求,然后发送方法调用,接收返回值。首页主要包括了用户注册登录、所有的房产价格信息、房屋信息、留言反馈。其中首页的界面如5.4所示。
登录用户账号后才可使用系统所有功能。具体操作为用户点击登录账号,在账号栏输入用户账号,密码栏输入用户密码,随后输入正确的验证码后点击登录,方可进入用户系统功能模块,密码错误用户名错误和验证码错误都会导致无法登录。
5.4房价预测大屏显示
大屏板块信息包括了房屋名称统计、价格趋势统计、房型统计、类型统计、区域统计。最终显示的界面如5.5所示。
三、关键代码
3.1 新闻公告模块,增删改查,以及推荐
def news_page(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
#获取全部列名
columns= news.getallcolumn( news, news)
#当前登录用户所在表
tablename = request.session.get("tablename")
#authColumn=list(__authTables__.keys())[0]
#authTable=__authTables__.get(authColumn)
# if authTable==tablename:
#params = request.session.get("params")
#req_dict[authColumn]=params.get(authColumn)
'''__authSeparate__此属性为真,params添加userid,后台只查询个人数据'''
try:
__authSeparate__=news.__authSeparate__
except:
__authSeparate__=None
if __authSeparate__=="是":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#当项目属性hasMessage为”是”,生成系统自动生成留言板的表messages,同时该表的表属性hasMessage也被设置为”是”,字段包括userid(用户id),username(用户名),content(留言内容),reply(回复)
#接口page需要区分权限,普通用户查看自己的留言和回复记录,管理员查看所有的留言和回复记录
try:
__hasMessage__=news.__hasMessage__
except:
__hasMessage__=None
if __hasMessage__=="是":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict["userid"]=request.session.get("params").get("id")
# 判断当前表的表属性isAdmin,为真则是管理员表
# 当表属性isAdmin=”是”,刷出来的用户表也是管理员,即page和list可以查看所有人的考试记录(同时应用于其他表)
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
# 当前表也是有管理员权限的表
if __isAdmin__ == "是" and 'news' != 'forum':
if req_dict.get("userid") and 'news' != 'chat':
del req_dict["userid"]
else:
#非管理员权限的表,判断当前表字段名是否有userid
if tablename!="users" and 'news'[:7]!='discuss'and "userid" in news.getallcolumn(news,news):
req_dict["userid"] = request.session.get("params").get("id")
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致],则对应的表有个隐藏属性authTable为”是”,那么该用户查看该表信息时,只能查看自己的
try:
__authTables__=news.__authTables__
except:
__authTables__=None
if __authTables__!=None and __authTables__!={}:
try:
del req_dict['userid']
# tablename=request.session.get("tablename")
# if tablename=="users":
# del req_dict['userid']
except:
pass
for authColumn,authTable in __authTables__.items():
if authTable==tablename:
params = request.session.get("params")
req_dict[authColumn]=params.get(authColumn)
username=params.get(authColumn)
break
q = Q()
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] =news.page(news, news, req_dict, request, q)
return JsonResponse(msg)
def news_autoSort(request):
'''
.智能推荐功能(表属性:[intelRecom(是/否)],新增clicktime[前端不显示该字段]字段(调用info/detail接口的时候更新),按clicktime排序查询)
主要信息列表(如商品列表,新闻列表)中使用,显示最近点击的或最新添加的5条记录就行
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
if "clicknum" in news.getallcolumn(news,news):
req_dict['sort']='clicknum'
elif "browseduration" in news.getallcolumn(news,news):
req_dict['sort']='browseduration'
else:
req_dict['sort']='clicktime'
req_dict['order']='desc'
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = news.page(news,news, req_dict)
return JsonResponse(msg)
def news_list(request):
'''
前台分页
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
req_dict = request.session.get("req_dict")
if req_dict.__contains__('vipread'):
del req_dict['vipread']
#获取全部列名
columns= news.getallcolumn( news, news)
#表属性[foreEndList]前台list:和后台默认的list列表页相似,只是摆在前台,否:指没有此页,是:表示有此页(不需要登陆即可查看),前要登:表示有此页且需要登陆后才能查看
try:
__foreEndList__=news.__foreEndList__
except:
__foreEndList__=None
if __foreEndList__=="前要登":
tablename=request.session.get("tablename")
if tablename!="users" and 'userid' in columns:
try:
req_dict['userid']=request.session.get("params").get("id")
except:
pass
#forrEndListAuth
try:
__foreEndListAuth__=news.__foreEndListAuth__
except:
__foreEndListAuth__=None
#authSeparate
try:
__authSeparate__=news.__authSeparate__
except:
__authSeparate__=None
if __foreEndListAuth__ =="是" and __authSeparate__=="是":
tablename=request.session.get("tablename")
if tablename!="users":
req_dict['userid']=request.session.get("params",{"id":0}).get("id")
tablename = request.session.get("tablename")
if tablename == "users" and req_dict.get("userid") != None:#判断是否存在userid列名
del req_dict["userid"]
else:
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
if __isAdmin__ == "是":
if req_dict.get("userid"):
# del req_dict["userid"]
pass
else:
#非管理员权限的表,判断当前表字段名是否有userid
if "userid" in columns:
try:
pass
except:
pass
#当列属性authTable有值(某个用户表)[该列的列名必须和该用户表的登陆字段名一致],则对应的表有个隐藏属性authTable为”是”,那么该用户查看该表信息时,只能查看自己的
try:
__authTables__=news.__authTables__
except:
__authTables__=None
if __authTables__!=None and __authTables__!={} and __foreEndListAuth__=="是":
try:
del req_dict['userid']
except:
pass
for authColumn,authTable in __authTables__.items():
if authTable==tablename:
params = request.session.get("params")
req_dict[authColumn]=params.get(authColumn)
username=params.get(authColumn)
break
if news.__tablename__[:7]=="discuss":
try:
del req_dict['userid']
except:
pass
q = Q()
msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
msg['data']['pageSize'] = news.page(news, news, req_dict, request, q)
return JsonResponse(msg)
def news_save(request):
'''
后台新增
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
if 'clicktime' in req_dict.keys():
del req_dict['clicktime']
tablename=request.session.get("tablename")
__isAdmin__ = None
allModels = apps.get_app_config('main').get_models()
for m in allModels:
if m.__tablename__==tablename:
try:
__isAdmin__ = m.__isAdmin__
except:
__isAdmin__ = None
break
#获取全部列名
columns= news.getallcolumn( news, news)
if tablename!='users' and req_dict.get("userid")!=None and 'userid' in columns and __isAdmin__!='是':
params=request.session.get("params")
req_dict['userid']=params.get('id')
error= news.createbyreq(news,news, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def news_info(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data = news.getbyid(news,news, int(id_))
if len(data)>0:
msg['data']=data[0]
if msg['data'].__contains__("reversetime"):
msg['data']['reversetime'] = msg['data']['reversetime'].strftime("%Y-%m-%d %H:%M:%S")
#浏览点击次数
try:
__browseClick__= news.__browseClick__
except:
__browseClick__=None
if __browseClick__=="是" and "clicknum" in news.getallcolumn(news,news):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=news.updatebyparams(news,news,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = ret
return JsonResponse(msg)
def news_detail(request,id_):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
data =news.getbyid(news,news, int(id_))
if len(data)>0:
msg['data']=data[0]
if msg['data'].__contains__("reversetime"):
msg['data']['reversetime'] = msg['data']['reversetime'].strftime("%Y-%m-%d %H:%M:%S")
#浏览点击次数
try:
__browseClick__= news.__browseClick__
except:
__browseClick__=None
if __browseClick__=="是" and "clicknum" in news.getallcolumn(news,news):
try:
clicknum=int(data[0].get("clicknum",0))+1
except:
clicknum=0+1
click_dict={"id":int(id_),"clicknum":clicknum}
ret=news.updatebyparams(news,news,click_dict)
if ret!=None:
msg['code'] = crud_error_code
msg['msg'] = retfo
return JsonResponse(msg)
def news_update(request):
'''
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
if req_dict.get("mima") and "mima" not in news.getallcolumn(news,news) :
del req_dict["mima"]
if req_dict.get("password") and "password" not in news.getallcolumn(news,news) :
del req_dict["password"]
try:
del req_dict["clicknum"]
except:
pass
error = news.updatebyparams(news, news, req_dict)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
def news_delete(request):
'''
批量删除
'''
if request.method in ["POST", "GET"]:
msg = {"code": normal_code, "msg": mes.normal_code, "data": {}}
req_dict = request.session.get("req_dict")
error=news.deletes(news,
news,
req_dict.get("ids")
)
if error!=None:
msg['code'] = crud_error_code
msg['msg'] = error
return JsonResponse(msg)
3.2密码修改
<template>
<div>
<el-form
:style='{"border":"1px solid #ddd","padding":"30px","boxShadow":"0 0px 0px #ddd","borderRadius":"5px","background":"#ffffff"}'
class="add-update-preview"
ref="ruleForm"
:rules="rules"
:model="ruleForm"
label-width="80px"
>
<el-form-item :style='{"margin":"0 0 20px 0"}' label="原密码" prop="password">
<el-input v-model="ruleForm.password" show-password></el-input>
</el-form-item>
<el-form-item :style='{"margin":"0 0 20px 0"}' label="新密码" prop="newpassword">
<el-input v-model="ruleForm.newpassword" show-password></el-input>
</el-form-item>
<el-form-item :style='{"margin":"0 0 20px 0"}' label="确认密码" prop="repassword">
<el-input v-model="ruleForm.repassword" show-password></el-input>
</el-form-item>
<el-form-item :style='{"padding":"0","margin":"0"}'>
<el-button :style='{"border":"0","cursor":"pointer","padding":"0","margin":"0 20px 0 0","outline":"none","color":"rgba(255, 255, 255, 1)","borderRadius":"4px","background":"#337ab7","width":"128px","lineHeight":"40px","fontSize":"14px","height":"40px"}' type="primary" @click="onUpdateHandler">确 定</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
export default {
data() {
return {
dialogVisible: false,
ruleForm: {},
user: {},
rules: {
password: [
{
required: true,
message: "密码不能为空",
trigger: "blur"
}
],
newpassword: [
{
required: true,
message: "新密码不能为空",
trigger: "blur"
}
],
repassword: [
{
required: true,
message: "确认密码不能为空",
trigger: "blur"
}
]
}
};
},
mounted() {
this.$http({
url: `${this.$storage.get("sessionTable")}/session`,
method: "get"
}).then(({ data }) => {
if (data && data.code === 0) {
this.user = data.data;
} else {
this.$message.error(data.msg);
}
});
},
methods: {
onLogout() {
this.$storage.remove("Token");
this.$router.replace({ name: "login" });
},
// 修改密码
onUpdateHandler() {
this.$refs["ruleForm"].validate(valid => {
if (valid) {
var password = "";
if (this.user.mima) {
password = this.user.mima;
} else if (this.user.password) {
password = this.user.password;
}
if (this.user.password) {
password = this.user.password;
} else if (this.user.password) {
password = this.user.password;
}
if (this.ruleForm.password != password) {
this.$message.error("原密码错误");
return;
}
if (this.ruleForm.newpassword != this.ruleForm.repassword) {
this.$message.error("两次密码输入不一致");
return;
}
this.user.password = this.ruleForm.newpassword;
this.user.mima = this.ruleForm.newpassword;
this.$http({
url: `${this.$storage.get("sessionTable")}/update`,
method: "post",
data: this.user
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "修改密码成功,下次登录系统生效",
type: "success",
duration: 1500,
onClose: () => {
}
});
} else {
this.$message.error(data.msg);
}
});
}
});
}
}
};
</script>
<style lang="scss" scoped>
.el-date-editor.el-input {
width: auto;
}
.add-update-preview .el-form-item /deep/ .el-form-item__label {
padding: 0 10px 0 0;
color: #666;
font-weight: 500;
width: 80px;
font-size: 14px;
line-height: 40px;
text-align: right;
}
.add-update-preview .el-form-item /deep/ .el-form-item__content {
margin-left: 80px;
}
.add-update-preview .el-input /deep/ .el-input__inner {
border: 1px solid #5479bb;
border-radius: 4px;
padding: 0 12px;
box-shadow: 1px 2px 3px #eee;
outline: none;
color: #aaa;
width: 400px;
font-size: 14px;
height: 40px;
}
.add-update-preview .el-select /deep/ .el-input__inner {
border: 1px solid #5479bb;
border-radius: 4px;
padding: 0 10px;
box-shadow: 1px 2px 3px #eee;
outline: none;
color: #aaa;
width: 200px;
font-size: 14px;
height: 40px;
}
.add-update-preview .el-date-editor /deep/ .el-input__inner {
border: 1px solid #5479bb;
border-radius: 4px;
padding: 0 10px 0 30px;
box-shadow: 1px 2px 3px #eee;
outline: none;
color: #aaa;
width: 200px;
font-size: 14px;
height: 40px;
}
.add-update-preview /deep/ .el-upload--picture-card {
background: transparent;
border: 0;
border-radius: 0;
width: auto;
height: auto;
line-height: initial;
vertical-align: middle;
}
.add-update-preview /deep/ .el-upload-list .el-upload-list__item {
border: 1px dashed #5479bb;
cursor: pointer;
border-radius: 6px;
color: #5479bb;
width: 200px;
font-size: 32px;
line-height: 120px;
text-align: center;
height: 120px;
}
.add-update-preview /deep/ .el-upload .el-icon-plus {
border: 1px dashed #5479bb;
cursor: pointer;
border-radius: 6px;
color: #5479bb;
width: 200px;
font-size: 32px;
line-height: 120px;
text-align: center;
height: 120px;
}
.add-update-preview .el-textarea /deep/ .el-textarea__inner {
border: 1px solid #5479bb;
border-radius: 4px;
padding: 12px;
box-shadow: 1px 2px 3px #eee;
outline: none;
color: #aaa;
width: 400px;
font-size: 14px;
height: auto;
}
</style>
四、其他案例截图
五、源码获取
如有其他选题或有选题疑问的,可以在评论区留言咨询
Python毕设项目选题源代码500个
Java毕设项目选题源代码1000个
微信小程序毕设项目源代码500个
PHP毕设项目源代码500个
Node.JS毕设项目源代码500个
.NET/ASP.NET毕设项目源代码500个
大家点赞、收藏、关注、评论啦 、查看👇🏻👇🏻👇🏻小卡片获取联系方式👇🏻👇🏻👇🏻