大数据专题-spark mysql python爬虫携程景点爬取(含虚拟机镜像)

news/2024/4/29 2:55:15/文章来源:https://blog.csdn.net/qq_31293575/article/details/127241921

 博主介绍:✌在职Java研发工程师、专注于程序设计、源码分享、技术交流、专注于Java技术领域

项目名称

大数据专题-spark mysql python爬虫携程景点爬取(含虚拟机镜像)

视频效果

大数据专题-spark mysql python爬虫携程景点

系统说明

一.问题定义解决

1.1 需要解决的问题

本次大作业报告主要解决的问题:

  1. 使用spark读取csv文件数据并分析数据。
  2. 使用spark将csv文件数据导入到mysql中。
  3. 使用sql查找数据库数据。
  4. 构建echarts框架的图表页面。
  5. 使用spark将分析的json数据输出。
  6. 使用eharts前端页面分析json数据进行展示。

1.2 具体所用方法及输入输出。

  1. 使用spark读取csv文件数据并分析数据。

首先构建基于spark框架的环境进行开发。本次报告环境是win10系统,所以需要下载对应的环境。

(1)Windows10 本地搭建单机版Spark开发环境

1、系统环境

OS:Windows10_x64 专业版

2、所需软件或工具

  • 8.0_131
  • spark-2.3.0-bin-hadoop2.7.tgz
  • hadoop-2.8.3.tar.gz
  • scala-2.11.8.zip
  • hadoop-common-2.2.0-bin-master.zip(主要使用里面的exe)
  • IntelliJ IDEA(版本:1.2 Build #IU-171.4249.32,built on April 21,2017)
  • scala-intellij-bin-2017.1.20.zip(IntelliJ IDEA scala插件)
  • apache-maven-3.5.0

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
5.数据库:MySql 5.7版本;
6.是否Maven项目:否;

技术栈

1. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jQuery

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/ 登录

运行截图

 用户管理控制层:

package com.houserss.controller;import javax.servlet.http.HttpSession;import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;import com.houserss.common.Const;
import com.houserss.common.Const.Role;
import com.houserss.common.ServerResponse;
import com.houserss.pojo.User;
import com.houserss.service.IUserService;
import com.houserss.service.impl.UserServiceImpl;
import com.houserss.util.MD5Util;
import com.houserss.util.TimeUtils;
import com.houserss.vo.DeleteHouseVo;
import com.houserss.vo.PageInfoVo;/*** Created by admin*/
@Controller
@RequestMapping("/user/")
public class UserController {@Autowiredprivate IUserService iUserService;/*** 用户登录* @param username* @param password* @param session* @return*/@RequestMapping(value = "login.do",method = RequestMethod.POST)@ResponseBodypublic ServerResponse<User> login(User user,String uvcode, HttpSession session){String code = (String)session.getAttribute("validationCode");if(StringUtils.isNotBlank(code)) {if(!code.equalsIgnoreCase(uvcode)) {return ServerResponse.createByErrorMessage("验证码不正确");}}ServerResponse<User> response = iUserService.login(user.getUsername(),user.getPassword());if(response.isSuccess()){session.setAttribute(Const.CURRENT_USER,response.getData());}return response;}}

管理员管理控制层:


package com.sxl.controller.admin;import java.util.List;
import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;import com.sxl.controller.MyController;@Controller("adminController")
@RequestMapping(value = "/admin")
public class AdminController extends MyController {@RequestMapping(value = "/index")public String frame(Model model, HttpServletRequest request)throws Exception {return "/admin/index";}@RequestMapping(value = "/main")public String main(Model model, HttpServletRequest request)throws Exception {return "/admin/main";}@RequestMapping(value = "/tj1")public String tj1(Model model, HttpServletRequest request)throws Exception {String sql="select DATE_FORMAT(insertDate,'%Y-%m-%d') dates,sum(allPrice) price from t_order order by DATE_FORMAT(insertDate,'%Y-%m-%d')  desc";List<Map> list = db.queryForList(sql);model.addAttribute("list", list);System.out.println(list);return "/admin/tj/tj1";}@RequestMapping(value = "/password")public String password(Model model, HttpServletRequest request)throws Exception {return "/admin/password";}@RequestMapping(value = "/changePassword")public ResponseEntity<String> loginSave(Model model,HttpServletRequest request,String oldPassword,String newPassword) throws Exception {Map admin = getAdmin(request);if(oldPassword.equals(admin.get("password").toString())){String sql="update t_admin set password=? where id=?";db.update(sql, new Object[]{newPassword,admin.get("id")});return renderData(true,"1",null);}else{return renderData(false,"1",null);}}
}

修改密码业务逻辑:


package com.sxl.controller.admin;import java.util.Map;import javax.servlet.http.HttpServletRequest;import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;import com.sxl.controller.MyController;@Controller("userController")
@RequestMapping(value = "/user")
public class UserController extends MyController {@RequestMapping(value = "/index")public String frame(Model model, HttpServletRequest request)throws Exception {return "/user/index";}@RequestMapping(value = "/main")public String main(Model model, HttpServletRequest request)throws Exception {return "/user/main";}@RequestMapping(value = "/password")public String password(Model model, HttpServletRequest request)throws Exception {return "/user/password";}@RequestMapping(value = "/changePassword")public ResponseEntity<String> loginSave(Model model,HttpServletRequest request,String oldPassword,String newPassword) throws Exception {Map user = getUser(request);if(oldPassword.equals(user.get("password").toString())){String sql="update t_user set password=? where id=?";db.update(sql, new Object[]{newPassword,user.get("id")});return renderData(true,"1",null);}else{return renderData(false,"1",null);}}@RequestMapping(value = "/mine")public String mine(Model model, HttpServletRequest request)throws Exception {
Map user =getUser(request);Map map = db.queryForMap("select * from t_user where id=?",new Object[]{user.get("id")});model.addAttribute("map", map);		return "/user/mine";}@RequestMapping(value = "/mineSave")public ResponseEntity<String> mineSave(Model model,HttpServletRequest request,Long id,String username,String password,String name,String gh,String mobile) throws Exception{int result = 0;String sql="update t_user set name=?,gh=?,mobile=? where id=?";result = db.update(sql, new Object[]{name,gh,mobile,id});if(result==1){return renderData(true,"操作成功",null);}else{return renderData(false,"操作失败",null);}}}

通用管理模块:

package com.sxl.controller;import java.nio.charset.Charset;
import java.util.Locale;
import java.util.ResourceBundle;import javax.servlet.http.HttpServletRequest;import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;import com.sxl.util.JacksonJsonUtil;
import com.sxl.util.StringUtil;
import com.sxl.util.SystemProperties;public class BaseController {public static final Long EXPIRES_IN = 1000 * 3600 * 24 * 1L;// 1天@Autowiredprivate SystemProperties systemProperties;/*** 获得配置文件内容*/public String getConfig(String key) {return systemProperties.getProperties(key);}/*** 返回服务器地址 like http://192.168.1.1:8441/UUBean/*/public String getHostUrl(HttpServletRequest request) {String hostName = request.getServerName();Integer hostPort = request.getServerPort();String path = request.getContextPath();if (hostPort == 80) {return "http://" + hostName + path + "/";} else {return "http://" + hostName + ":" + hostPort + path + "/";}}/**** 获取当前的website路径 String*/public static String getWebSite(HttpServletRequest request) {String returnUrl = request.getScheme() + "://"+ request.getServerName();if (request.getServerPort() != 80) {returnUrl += ":" + request.getServerPort();}returnUrl += request.getContextPath();return returnUrl;}/*** 初始化HTTP头.* * @return HttpHeaders*/public HttpHeaders initHttpHeaders() {HttpHeaders headers = new HttpHeaders();MediaType mediaType = new MediaType("text", "html",Charset.forName("utf-8"));headers.setContentType(mediaType);return headers;}/*** 返回 信息数据* * @param status* @param msg* @return*/public ResponseEntity<String> renderMsg(Boolean status, String msg) {if (StringUtils.isEmpty(msg)) {msg = "";}String str = "{\"status\":\"" + status + "\",\"msg\":\"" + msg + "\"}";ResponseEntity<String> responseEntity = new ResponseEntity<String>(str,initHttpHeaders(), HttpStatus.OK);return responseEntity;}/*** 返回obj数据* * @param status* @param msg* @param obj* @return*/public ResponseEntity<String> renderData(Boolean status, String msg,Object obj) {if (StringUtils.isEmpty(msg)) {msg = "";}StringBuffer sb = new StringBuffer();sb.append("{");sb.append("\"status\":\"" + status + "\",\"msg\":\"" + msg + "\",");sb.append("\"data\":" + JacksonJsonUtil.toJson(obj) + "");sb.append("}");ResponseEntity<String> responseEntity = new ResponseEntity<String>(sb.toString(), initHttpHeaders(), HttpStatus.OK);return responseEntity;}/**** 获取IP(如果是多级代理,则得到的是一串IP值)*/public static String getIpAddr(HttpServletRequest request) {String ip = request.getHeader("x-forwarded-for");if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getHeader("Proxy-Client-IP");}if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getHeader("WL-Proxy-Client-IP");}if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {ip = request.getRemoteAddr();}if (ip != null && ip.length() > 0) {String[] ips = ip.split(",");for (int i = 0; i < ips.length; i++) {if (!"unknown".equalsIgnoreCase(ips[i])) {ip = ips[i];break;}}}return ip;}/*** 国际化获得语言内容* * @param key*            语言key* @param args* @param argsSplit* @param defaultMessage* @param locale* @return*/public static String getLanguage(String key, String args, String argsSplit,String defaultMessage, String locale) {String language = "zh";String contry = "cn";String returnValue = defaultMessage;if (!StringUtil.isEmpty(locale)) {try {String[] localeArray = locale.split("_");language = localeArray[0];contry = localeArray[1];} catch (Exception e) {}}try {ResourceBundle resource = ResourceBundle.getBundle("lang.resource",new Locale(language, contry));returnValue = resource.getString(key);if (!StringUtil.isEmpty(args)) {String[] argsArray = args.split(argsSplit);for (int i = 0; i < argsArray.length; i++) {returnValue = returnValue.replace("{" + i + "}",argsArray[i]);}}} catch (Exception e) {}return returnValue;}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_398734.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Vue组件之间的数据共享详解

目录前言一&#xff0c;props的作用二&#xff0c;父向子传值2.1 子元素2.2 父元素2.3 整体代码三&#xff0c;子向父传值3.1 子组件3.2 父组件3.3 整体代码四&#xff0c;兄弟之间的数据传递4.1 事件总线EventBus介绍(面试高频&#xff09;4.2 传值方4.3 接收方后记前言 组件…

Servlet - Filtering (过滤器))

[TOC](Servlet - Filtering (过滤器) ) 1. What 1.1 什么是Filter Servlet过滤器Filter是一个小型的web组件&#xff0c;它们通过拦截请求和响应&#xff0c;以便查看、提取或以某种方式操作客户端和服务器之间交换的数据&#xff0c;实现“过滤”的功能。Filter通常封装了一…

深度神经网络的优化算法,进化算法优化神经网络

有哪些手段可以提升深度神经网络的泛化性能 人工神经网络以其智能性见长&#xff0c;那么神经网络能真的学到一个映射的本质吗&#xff1f;也就是说&#xff0c;对一个映射给出一定的必要的训练样本训练后&#xff0c;网络能否对样本以外的样本给出较为准确的预测。 泛化能力…

概率论与数理统计学习:随机向量(三)——知识总结与C语言实现案例

hello&#xff0c;大家好 这里是第八期概率论与数理统计的学习&#xff0c;我将用这篇博客去总结这期的知识点以及实现用C语言去做题的过程。 本期知识点&#xff1a; 条件分布 条件分布的概念离散型随机变量的条件概率分布连续型随机变量的条件概率密度 随机变量的独立性 那…

ROS学习笔记三(TF的类)

1.数据类型 数据类型定义在tf/transform_datatypes.h.里 1.1 基本数据类型(Quaternion, Vector, Point, Pose, Transform) TypetfQuaterniontf::QuaternionVectortf::Vector3Pointtf::PointPosetf::PoseTransformtf::Transform 1.2 tf::Stamped tf::Stamped在上面的数据类型…

RocketMQ 5.0:无状态代理模式的探索与实践

本文作者&#xff1a;金吉祥&#xff0c; Apache RocketMQ PMC Member&#xff0c;阿里云智能高级技术专家 背景 首先&#xff0c;让我们来看下是遇到了哪些痛点问题&#xff0c;促使我们去探索一种无状态代理的RocketMQ新架构的&#xff1b; RocketMQ 拥有一套极简的架构&am…

安卓投屏 QtScrcpy

一、电脑安装adb 版本大于1.0.40以上 40不行 adb 1.0.41下载链接 链接&#xff1a;https://pan.baidu.com/s/1WIPI-p7a4ErTLFYHaTC2kw?pwdadbt 提取码&#xff1a;adbt 安装参考 https://blog.csdn.net/M7_xbc/article/details/122957311 二、打开无线调试并且配对 手机打…

驱动开发(10/10-林雪阵)

终端输入1--->LED1点亮 终端输入2--->LED2点亮 终端输入3--->LED3点亮 终端输入0--->LED熄灭 chdev.c (底层驱动代码&#xff09; #include <linux/init.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/uaccess.h>…

【webrtc】rtp 扩展头的ID

ietf 文档地址扩展头的uri 是固定的,因此识别扩展是通过uri地址,而非ID。rtp 扩展头是有个ID的 文档的说法 : 是本地的id,15保留,只可以小于15 本地标识符值 15 保留用于将来的扩展和 不得用作标识符。如果 ID 值 15 是 遇到,它的长度字段应该被忽略,处理 整个扩展应在该…

redis之AOF和RDB持久化

写在前面 因为redis数据是基于内存的&#xff0c;为了避免服务器重启或者是宕机导致数据全部丢失&#xff0c;提供了数据持久化机制&#xff0c;即AOF(Append Only File)日志和RDB快照&#xff0c;接下来我们分别看下。 1&#xff1a;AOF 1.1&#xff1a;AOF日志的实现 首先…

(附源码)计算机毕业设计SSM政府项目管理平台

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

回顾——PCB绘制

目录 一、原理图库原理图 二、PCB库 三、PCB 一、原理图库原理图 新建工程&#xff1a;文件——New——Project——Name&#xff08;这里复制一下&#xff09;自己选择保存路径 添加文件&#xff1a; 保存工程&#xff1a;(粘贴) 绘制原理图库、原理图 侧边栏消失&…

虚拟社会、区块链和元宇宙

1986年&#xff0c;早期的互联网供应商Quantum Link和娱乐公司Lucasfilm Games发布了第一款MMO游戏名为&#xff1a;《Habitat》基于虚拟角色的社交世界&#xff0c;玩家可以通过300波特的调制解调器(每分钟0.08美元)和用户的Commodore 64(595美元&#xff0c;按今天的价格约为…

Vue 动态换肤

效果如图&#xff1a; 源代码&#xff1a; <template><div :class"[son${temp}]" class"demo3">这是四点零八分的北京<br/>一片手的海浪翻动<br/>这是四点零八分的北京<br/>一声雄伟的汽笛长鸣<br/>北京车站高大的建…

Kafka监控EFAK(Kafka-eagle)部署与踩坑详细记录

环境 阿里云服务器centoskafka 2.4.1 &#xff08;1.1以上版本都能支持&#xff0c;低版本不太清楚了&#xff09;efak 3.0.1 当前时间官网下载的最新版&#xff08;原名叫kafka-eagle&#xff09;efak官网&#xff1a;http://www.kafka-eagle.org/jdk8 部署好的UI 部署流程 …

kafka系列——安装部署,相关命令,配置文件,底层存储结构,log和index文件

点击上方“罗晓胜”&#xff0c;马上关注&#xff0c;您的支持对我帮助很大 / 前言 / Kafka是最初由Linkedin公司开发&#xff0c;用scala语言编写的&#xff0c;是一个分布式、支持分区的&#xff08;partition&#xff09;、多副本的&#xff08;replica&#xff09;&…

时光机特效在哪里?推荐这三个实用软件给你

现如今有一款时光穿梭机的特效软件非常热门&#xff0c;它具有让照片中的人变年轻或者变老的功能&#xff0c;能让我们看到过去以及未来自己的样子&#xff0c;也能给我们枯燥的生活增添一点趣味感。那么大家是不是已经迫不及待地想知道时光穿梭机特效滤镜在哪了呢&#xff1f;…

Linux学习 -- docker的commit命令和本地镜像到云端

commit命令本地镜像到云端 一、commit命令 我们在使用镜像新建容器后&#xff0c;容器只是具有简易的Linux的功能&#xff0c;不具备一些常用的功能&#xff0c;如vim功能&#xff0c;因此我们需要给容器加上一些我们需要的功能。 使用如下命令&#xff1a; docker commit提交容…

不使用第三方库怎么实现【前端引导页】功能?

前言 随着应用功能越来越多&#xff0c;繁多而详细的功能使用和说明文档&#xff0c;已经不能满足时代追求 快速 的需求&#xff0c;而 引导页&#xff08;或分步引导&#xff09; 本质就是 化繁为简&#xff0c;将核心功能以更简单、简短、明了的文字指引用户去使用对应的功能…

Oracle数据库 | SQL语句解析

个人主页&#xff1a;&#x1f497;wei_shuo的个人主页 &#x1f3c0; Hello World &#xff01;&#x1f3c0; 文章目录一.Oracle启动及登录1.1 服务手启动即关闭1.2 SQL* PLUS命令二. 表的创建和维护2.1 创建表2.2 修改表2.3 重命名表2.4 截断表2.5 删除表三. 数据完整性与约…