赞
踩
博主介绍:✌全网粉丝10W+,前互联网大厂软件研发、集结硕博英豪成立工作室。专注于计算机相关专业毕业设计项目实战6年之久,选择我们就是选择放心、选择安心毕业✌感兴趣的可以先收藏起来,点赞、关注不迷路✌
毕业设计:2023-2024年计算机毕业设计1000套(建议收藏)
毕业设计:2023-2024年最新最全计算机专业毕业设计选题汇总
技术栈:
Python语言、Django框架 、MySQL数据库、Vue框架、Scrapy爬虫、Echarts可视化、懂车帝网数据
(1)新能源汽车详细页面
(2)汽车数据可视化分析
(3)新能源汽车信息页面和选车页面
(4)可视化分析
(5)价格范围分布分析
(6)新能源汽车销量榜单
(7)新能源汽车差评榜单
(8)后台数据管理
(9)新能源汽车数据管理
(10)懂车帝网站数据爬取
这款汽车信息网站是基于多项技术和框架设计的全面的汽车信息展示及查询系统。其中,采用了Python Django框架和Scrapy爬虫技术实现数据的抓取和处理,结合MySQL数据库进行数据存储和管理,利用Vue3、Element-Plus、ECharts以及Pinia等前端技术实现了丰富的数据可视化展示和用户交互功能。
该系统主要包含以下几个模块:
1.Scrapy爬虫:使用Scrapy框架抓取了“懂车帝”网站的汽车及销量数据,以及“车质网”的汽车投诉数据,并将这些数据存储进MySQL数据库中,为后续的展示和查询提供了数据基础。
这个项目使用了很多技术组合,下面是各个部分所用到的主要技术:
各模块功能实现:
可在后台增删改查管理所有数据
使用Django SimpleUI实现管理后台,并且配置相应的权限控制,管理员可以登录后台,对汽车数据和投诉数据进行增删改查和其他操作。
用户登陆注册
(1)后端实现
from django.shortcuts import render from datetime import datetime, timedelta from .models import * from django.http.response import JsonResponse from itertools import groupby from .models import * import json from django.http.response import HttpResponse from django.shortcuts import render from django.http import JsonResponse from pyecharts import options as opts from pyecharts.charts import Map, Grid, Bar, Line, Pie, WordCloud, Radar, Timeline from pyecharts.faker import Faker from pyecharts.commons.utils import JsCode from pyecharts.options.charts_options import MapItem from datetime import datetime, time from django.core.paginator import Paginator from django.db.models import Q, F from pyecharts.globals import SymbolType from django.db.models import Sum, Count, Max, Min, Avg from collections import Counter from requests_html import requests from itertools import chain from functools import lru_cache def car_sales_rank(request): # 获取请求体中的数据 body = request.json # 获取请求体中的月份 month = body.get("month") # 定义查询条件 q = Q() # 根据月份设置查询条件 if month == "1y": # 获取当前日期及1年前的日期 today = datetime.now().date() one_year_ago = today - timedelta(days=365) # 设置查询条件 q &= Q( month__gte=one_year_ago.strftime("%Y%m"), month__lte=today.strftime("%Y%m") ) elif month == "6m": # 近半年,即6个月 today = datetime.now().date() half_year_ago = today - timedelta(days=365 // 2) # 设置查询条件 q &= Q( month__gte=half_year_ago.strftime("%Y%m"), month__lte=today.strftime("%Y%m") ) else: q &= Q(month=month) # 统计各个车系一年内的总销量,并按照销量进行排序和排名 result = ( CarSale.objects.filter(q) .values("series_id", "series_name") .annotate(total_sales=Sum("rank_value")) .order_by("-total_sales") ) # 对结果进行排名 result_list = list(result) for i, item in enumerate(result_list): item["sales_rank"] = i + 1 # 分页处理数据 pagesize = body.get("pagesize", 20) page_num = body.get("page", 1) paginator = Paginator(result_list, pagesize) # 创建Paginator对象 page = paginator.get_page(page_num) # 获取指定页码的数据 result = list(page.object_list) # 获取每个车系的详细信息,并将其添加到结果中 for i in result: car_series = to_dict([CarSeries.objects.get(series_id=i["series_id"])])[0] i.update(**car_series) # 返回分页后的结果 return JsonResponse({"total": paginator.count, "records": result}) def car_issue_rank(request): body = request.json stime = body.get("stime") type = body.get("type") q = Q() if stime == "1y": # 获取当前日期及1年前的日期 today = datetime.now().date() one_year_ago = today - timedelta(days=365) q &= Q( stime__gte=one_year_ago.strftime("%Y-%m-%d"), stime__lte=today.strftime("%Y-%m-%d"), ) elif stime == "6m": # 近半年,即6个月 today = datetime.now().date() half_year_ago = today - timedelta(days=365 // 2) q &= Q( stime__gte=half_year_ago.strftime("%Y-%m-%d"), stime__lte=today.strftime("%Y-%m-%d"), ) else: q &= Q(stime=stime) if type: q &= Q(type=type) # 统计各个车系一年内的总问题数,并按照问题数进行排序和排名 result = ( CarIssue.objects.filter(q) .values("series_id", "series_name") .annotate(total_issues=Sum("count")) .order_by("-total_issues") ) # 对结果进行排名 result_list = list(result) for i, item in enumerate(result_list): item["issues_rank"] = i + 1 # 分页处理数据 pagesize = body.get("pagesize", 20) page_num = body.get("page", 1) paginator = Paginator(result_list, pagesize) # 创建Paginator对象 page = paginator.get_page(page_num) # 获取指定页码的数据 result = list(page.object_list) for i in result: car_series = to_dict([CarSeries.objects.get(series_id=i["series_id"])])[0] counter = Counter() for x in CarIssue.objects.filter(q, series_id=i["series_id"]).values_list( "dxwt", flat=True ): counter.update(dict([(j["ctiTitle"], j["count"]) for j in x])) i["issues"] = counter.most_common(10) i.update(**car_series) return JsonResponse({"total": paginator.count, "records": result}) def get_detail(request): body = request.json id = body.get("id") o = CarSeries.objects.get(pk=id) o = to_dict(o, single=True) o["brand"] = to_dict(Brand.objects.get(brand_id=o["brand_id"]), single=True) return JsonResponse(o) def car_360_color_pic(request): body = request.json id = body.get("id") try: color_pic_list = requests.get( f"https://www.dongchedi.com/motor/pc/car/series/car_360_color_pic?aid=1839&app_name=auto_web_pc&series_id={id}" ).json()["data"]["color_pic_list"] except: color_pic_list = [] return JsonResponse(color_pic_list, safe=False) def radar_chart(request): body = request.json id = body.get("id") # 从数据库中读取评分数据 car_series = CarSeries.objects.get(series_id=id) color = "#f4cf63" # 转换数据范围 min_score = 1 max_score = 500 scale = 5 comfort_score = car_series.comfort_score / max_score * scale appearance_score = car_series.appearance_score / max_score * scale configuration_score = car_series.configuration_score / max_score * scale control_score = car_series.control_score / max_score * scale power_score = car_series.power_score / max_score * scale space_score = car_series.space_score / max_score * scale interiors_score = car_series.interiors_score / max_score * scale total_score = round(car_series.total_score / max_score * scale, 2) def car_series_analysis(request): low_price_data = {} for i in range(7): low_price_data[str(i)] = 0 for car_series in CarSeries.objects.all(): if car_series.dealer_low_price is not None: if car_series.dealer_low_price < 10: low_price_data["0"] += 1 elif car_series.dealer_low_price < 15: low_price_data["1"] += 1 elif car_series.dealer_low_price < 20: low_price_data["2"] += 1 elif car_series.dealer_low_price < 25: low_price_data["3"] += 1 elif car_series.dealer_low_price < 30: low_price_data["4"] += 1 elif car_series.dealer_low_price < 40: low_price_data["5"] += 1 else: low_price_data["6"] += 1 bar = ( Bar() .add_xaxis(["0-10万", "10-15万", "15-20万", "20-25万", "25-30万", "30-40万", "50万以上"]) .add_yaxis( "车系数量", [ low_price_data["0"], low_price_data["1"], low_price_data["2"], low_price_data["3"], low_price_data["4"], low_price_data["5"], low_price_data["6"], ], bar_width=50, ) .set_global_opts( title_opts=opts.TitleOpts(title="价格范围数量分布图", pos_left="center", pos_top=0), legend_opts=opts.LegendOpts(is_show=False), xaxis_opts=opts.AxisOpts( name="价格范围", axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"), ), yaxis_opts=opts.AxisOpts(name="车系数量"), ) ) return HttpResponse(bar.dump_options(), content_type="aplication/json")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。