【Vue+Django】Training Management Platform分页功能 - 20230621

news2024/9/28 21:25:50

需求描述

分页显示数据,避免造成服务器宕机。

Django:根据pageNum返回数据切片

Views.py写入业务逻辑

# 数据接口:暴露trs_training_and_test_record数据
def api_trs_training_and_test_record(request,myDateS,myDateE,mySystem,category,EmployeeID,courseName,pageNum=1):

    print('api_trs_training_and_test_record收到数据请求,参数为',myDateS,myDateE,mySystem,category,EmployeeID,courseName,pageNum)

    # ORM取得数据
    data_all = trs_training_and_test_record.objects.all()
    data_count = trs_training_and_test_record.objects.count()
    data_choose = data_all
    pageNum = int(pageNum)

    # 筛选&转码
    if myDateS:
        data_choose = data_choose.filter(Start_Date__gte=myDateS)
    if myDateE:
        data_choose = data_choose.filter(End_Date__lte=myDateE)
    if category:
        if category == 'training':
            data_choose = data_choose.filter(Type='課程')
        elif category == 'test':
            data_choose = data_choose.filter(Q(Type='考試')|Q(Type='考核'))
        elif category == 'All':
            pass
    if EmployeeID and EmployeeID !='NA':
        data_choose = data_choose.filter(Employee_NO=EmployeeID)
    if courseName and courseName !='NA':
        data_choose = data_choose.filter(Course__icontains=courseName)

    # 记录页码
    total = data_choose.count()

    # 分页,默认10笔数据为一页
    if data_choose:
        if (pageNum*10 >= 10) and (pageNum*10 <= data_count):
            data_choose = data_choose[(pageNum-1)*10:pageNum*10]
        elif (pageNum*10 >= 0) and (pageNum*10 > data_count) and (data_count<10):
            data_choose = data_choose[0:data_count]
        elif (pageNum*10 >= 10) and ((pageNum-1)*10 <= data_count) and (pageNum*10 > data_count):
            data_choose = data_choose[(pageNum-1)*10:data_count]

    # 初始化data
    data = []


    # 将数据塞进去data
    for each_queryset in data_choose:
        temp_data = {
                  'training_system': 'TRS',
                  'Location': each_queryset.Location,
                  'Function_Code': each_queryset.Function_Code,
                  'Function_Name': each_queryset.Function_Name,
                  'Plant': each_queryset.Plant,
                  'Dept': each_queryset.Dept,
                  'Employee_NO': each_queryset.Employee_NO,
                  'Name': each_queryset.Name,
                  'Grade_Range': each_queryset.Grade_Range,
                  'Training_Type': each_queryset.Training_Type,
                  'Priority': each_queryset.Priority,
                  'Type': each_queryset.Type,
                  'Course': each_queryset.Course,
                  'Schedule_Code': each_queryset.Schedule_Code,
                  'Schedule_Name': each_queryset.Schedule_Name,
                  'Course_or_Test': each_queryset.Course_or_Test,
                  'Delivery_Way_or_Test_Way': each_queryset.Delivery_Way_or_Test_Way,
                  'Start_Date': str(each_queryset.Start_Date),
                  'End_Date': str(each_queryset.End_Date),
                  'Present_Status': each_queryset.Present_Status,
                  'Pass_Score': each_queryset.Pass_Score,
                  'Listening_Score': each_queryset.Listening_Score,
                  'Reading_Score': each_queryset.Reading_Score,
                  'Score': each_queryset.Score,
                  'Pass_YN': each_queryset.Pass_YN,
                  'Effective_Date': each_queryset.Effective_Date,
                  'Duration': each_queryset.Duration,
                  'Venue': each_queryset.Venue,
                  'Trainer_Assesor': each_queryset.Trainer_Assesor,
                },
        data.append(temp_data)

    # 将data转化为trs_training_and_test_record_data
    trs_training_and_test_record_data = {
        'data':  data,
        'pageSize': 10,
        'pageNum':pageNum,
        'data_count':data_count,
        'total':total,

    }
    print('api_trs_training_and_test_record发送数据')

    # 暴露api
    return HttpResponse(json.dumps(trs_training_and_test_record_data,ensure_ascii=False,indent=4), content_type='application/json')

urls.py

    path('api/api_trs_down_load_training_and_test_record/<myDateS>/<myDateE>/<mySystem>/<category>/<EmployeeID>/<courseName>/', views.trs_down_load_training_and_test_record, name='trs_down_load_training_and_test_record'),

Vue前端

index.vue写入样式
主要逻辑如下:

  1. 按照系统不同,来使用v-if显示不同系统数据。
  2. GoQuery(myDate,mySystem,category,EmployeeID,courseName,pageNum)传入pageNum,以便服务器切片返回数据。
  3. 使用ElementUI中分页组件的回调参数val。@next-click=“handlenextClick”。在这里插入图片描述
  4. ElementUI中分页组件尽量使用state的数据。:total=TrsTrainingTestData.total
<template>
  <div class="container-fluid">
    <!-- 筛选栏 -->
    <el-row class="tac p-3">
      <el-col span="24">
        <h3>数据汇总</h3>
        <div class="block py-1">
          <span class="demonstration">日期筛选</span>
          <span class="demonstration">&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <el-date-picker 
            value-format="yyyy-MM-dd"
            v-model="myDate"
            type="daterange"
            align="right"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions">
          </el-date-picker>
        </div>

        <div class="block py-1">
          <span class="demonstration">训练系统</span>
          <span class="demonstration">&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <span>
            <el-radio-group v-model="mySystem">
              <el-radio-button label="TRS" :mySystem="TRS"></el-radio-button>
              <el-radio-button label="CSOD" :mySystem="CSOD"></el-radio-button>
              <el-radio-button label="DLT" :mySystem="DLT"></el-radio-button>
            </el-radio-group>
          </span>
        </div>

        <div class="block py-1">
          <span class="demonstration">关键指标</span>
          <span class="demonstration">&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <span>
            <el-radio-group v-model="category">
              <el-radio-button label="All" :category="All">All</el-radio-button>
              <el-radio-button label="training" :category="training">培训数据</el-radio-button>
              <el-radio-button label="test" :category="test">考试数据</el-radio-button>
            </el-radio-group>
          </span>
        </div>

        <div class="block py-1">
          <span class="demonstration">员工工号</span>
          <span class="demonstration">&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <span>
            <el-input 
              class="w-25"
              placeholder="请输入内容"
              v-model="EmployeeID"
              clearable>
            </el-input>
          </span>
        </div>

        <div class="block py-1">
          <span class="demonstration">课程名称</span>
          <span class="demonstration">&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <span>
            <el-input 
              class="w-25"
              placeholder="请输入内容"
              v-model="courseName"
              clearable>
            </el-input>
          </span>
          <span class="demonstration">&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <span class="float-left">
            <el-button type="info" plain  @click="GoQuery(myDate,mySystem,category,EmployeeID,courseName,pageNum)">查询</el-button>
            <el-button type="info" plain  @click="DownLoadExcel(myDate,mySystem,category,EmployeeID,courseName)">下载</el-button>
          </span>
        </div>

      </el-col>


    </el-row>


    

    <!-- TRS -->
    <el-row class="tac" v-if="mySystem=='TRS'">
      <el-col span="24">
        <table class="table table-striped table-sm table-bordered text-center">
                <thead>
                    <tr class="" style="color:White;background-color:#3366FF;font-family:微軟正黑體,Tahoma,Arial,微軟雅黑體;font-size:15px;">
                        <th scope="col">训练类别</th>
                        <th scope="col">厂别</th>
                        <th scope="col">部门代码</th>
                        <th scope="col">人员工号</th>
                        <th scope="col">人员姓名</th>
                        <th scope="col">知识点名称</th>
                        <th scope="col">培训日期</th>
                        <th scope="col">时间</th>
                        <th scope="col">培训地点</th>
                        <th scope="col">培训讲师</th>
                    </tr>
                </thead>

                <!-- TRS -->
                <tr v-for="item in TrsTrainingTestData.data" :key="item.Employee_NO" valign="middle" style="color:Black;border-color:#E0E0E0;font-size:15px;">
                        <td class="col">{{ item[0].training_system }}</td>
                        <td class="col">{{ item[0].Plant }}</td>
                        <td class="col">{{ item[0].Dept }}</td>
                        <td class="col">{{ item[0].Employee_NO }}</td>
                        <td class="col">{{ item[0].Name }}</td>
                        <td class="col">{{ item[0].Schedule_Name }}</td>
                        <td class="col">{{ item[0].Start_Date }}</td>
                        <td class="col">{{ item[0].Start_Date }}</td>
                        <td class="col">{{ item[0].Venue }}</td>
                        <td class="col"></td>
                  </tr>
            </table>
      </el-col>
    </el-row>

    <!-- 页码 -->
    <el-row class="tac" v-if="mySystem=='TRS'">
      <el-col span="24">
        <el-pagination
          background
          layout="prev, pager, next"
          :total=TrsTrainingTestData.total
          @current-change="handlenextClick"
          @prev-click="handlenextClick"
          @next-click="handlenextClick"
          >
        </el-pagination>
      </el-col>
    </el-row>
    


    <!-- CSOD -->
    <el-row class="tac" v-if="mySystem=='CSOD'">
      <el-col span="24">
        <table class="table table-striped table-sm table-bordered text-center">
                <thead>
                    <tr class="" style="color:White;background-color:#3366FF;font-family:微軟正黑體,Tahoma,Arial,微軟雅黑體;font-size:15px;">
                        <th scope="col">训练类别</th>
                        <th scope="col">厂别</th>
                        <th scope="col">部门代码</th>
                        <th scope="col">人员工号</th>
                        <th scope="col">人员姓名</th>
                        <th scope="col">知识点名称</th>
                        <th scope="col">培训日期</th>
                        <th scope="col">时间</th>
                        <th scope="col">培训地点</th>
                        <th scope="col">培训讲师</th>
                    </tr>
                </thead>

                <!-- CSOD -->
                <tr v-for="item in CsodTrainingTestData.data" :key="item.Employee_NO" valign="middle" style="color:Black;border-color:#E0E0E0;font-size:15px;">
                        <td class="col">{{ item[0].training_system }}</td>
                        <td class="col"></td>
                        <td class="col"></td>
                        <td class="col">{{ item[0].USER_ID }}</td>
                        <td class="col">{{ item[0].USER }}</td>
                        <td class="col">{{ item[0].TRAINING_TITLE }}</td>
                        <td class="col">{{ item[0].TRAINING_RECORD_DATE }}</td>
                        <td class="col">{{ item[0].TRAINING_RECORD_DATE }}</td>
                        <td class="col"></td>
                        <td class="col">{{ item[0].Instructor_Full_Name }}</td>
                </tr>
            </table>
      </el-col>
    </el-row>

    <!-- 页码 -->
    <el-row class="tac" v-if="mySystem=='CSOD'">
      <el-col span="24">
        <el-pagination
          background
          layout="prev, pager, next"
          :total=CsodTrainingTestData.total
          @current-change="handlenextClick"
          @prev-click="handlenextClick"
          @next-click="handlenextClick"
          >
        </el-pagination>
      </el-col>
    </el-row>



  </div>


</template>

<script>
  import { mapState } from 'vuex'
  export default {
    data() {
    return {
      pageNum:1,
      myDate:[],
      mySystem:'TRS',
      category: 'training',
      EmployeeID:'',
      courseName:'',
      pageNum:1,
      pageSize:10,
      reqTrsTrainingTestData:{'data':''},
      //日期筛选
      pickerOptions: {
          shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }]
        },

    };
  },
    mounted() {
    },
    computed: {
      ...mapState({
        DLTOrientData: (state) => state.home.DLTOrientData,
        DLTGeneralData: (state) => state.home.DLTGeneralData,
        DLTSkillTrainingData: (state) => state.home.DLTSkillTrainingData,
        DLTSkillLevelTrainingData: (state) => state.home.DLTSkillLevelTrainingData,
        TrsTrainingTestData: (state) => state.home.TrsTrainingTestData,
        TrsTrainerMaintainData: (state) => state.home.TrsTrainerMaintainData,
        CsodTrainingTestData: (state) => state.home.CsodTrainingTestData,
      }),
    },

    methods: {
      GoQuery(myDate,mySystem,category,EmployeeID,courseName,pageNum){
        // 初始化值
        var today=new Date();
        console.log('today',today)
        if (mySystem == 'TRS'){
          if(myDate == ''){
            //程序bug:today.getMonth()+1表示当前月
            myDate = [today.getFullYear()+"-"+(today.getMonth())+"-"+today.getDate(),
                      today.getFullYear()+"-"+(today.getMonth()+1)+"-"+today.getDate()
                    ];
          }
          if(EmployeeID == ''){EmployeeID = 'NA'}
          if(courseName == ''){courseName = 'NA'}
          this.$store.dispatch('getTrsTrainingTestData',
            {
                "myDateS":myDate[0],
                "myDateE":myDate[1],
                "mySystem":mySystem,
                "category":category,
                "EmployeeID":EmployeeID,
                "courseName":courseName,
                "pageNum":pageNum,
            })
        }
        if (mySystem == 'CSOD'){
          if(myDate == ''){
            //程序bug:today.getMonth()+1表示当前月
            myDate = [today.getFullYear()+"-"+(today.getMonth())+"-"+today.getDate(),
                      today.getFullYear()+"-"+(today.getMonth()+1)+"-"+today.getDate()
                    ];
          }
          if(EmployeeID == ''){EmployeeID = 'NA'}
          if(courseName == ''){courseName = 'NA'}
          this.$store.dispatch('getCsodTrainingTestData',
            {
                "myDateS":myDate[0],
                "myDateE":myDate[1],
                "mySystem":mySystem,
                "category":category,
                "EmployeeID":EmployeeID,
                "courseName":courseName,
                "pageNum":pageNum,
            })
        }

        if (mySystem == 'DLT'){
          this.$store.dispatch('getDLTOrientData', 
            {
                // "myDate":myDate,
                "mySystem":mySystem,
                "category":category,
                "courseName":courseName,
            })
        }

        console.log(123,myDate,mySystem,category,EmployeeID,courseName,pageNum)
      },

      handlenextClick(val){
        //把回调参数val给pageNum
        this.GoQuery(this.myDate,this.mySystem,this.category,this.EmployeeID,this.courseName,val)
        console.log('当前页码:',val)
      },

      DownLoadExcel(myDate,mySystem,category,EmployeeID,courseName){

        //初始值
        var today=new Date();
        if(myDate == ''){
            //程序bug:today.getMonth()+1表示当前月
            myDate = [today.getFullYear()+"-"+(today.getMonth())+"-"+today.getDate(),
                      today.getFullYear()+"-"+(today.getMonth()+1)+"-"+today.getDate()
                    ];
          }
        if(EmployeeID == ''){EmployeeID = 'NA'}
        if(courseName == ''){courseName = 'NA'}
        if (mySystem == 'TRS'){
          window.open('http://127.0.0.1:8000/api/api_trs_down_load_training_and_test_record/'+myDate[0]+'/'+myDate[1]+'/'+mySystem+'/'+category+'/'+EmployeeID+'/'+courseName+'/')
        }
        if (mySystem == 'CSOD'){
          window.open('http://127.0.0.1:8000/api/api_csod_down_load_training_and_test_record/'+myDate[0]+'/'+myDate[1]+'/'+mySystem+'/'+category+'/'+EmployeeID+'/'+courseName+'/')
        }        

       console.log('DownLoadExcel',mySystem)
      },



    },
  }
</script>

api请求数据接口


//请求TRS
export const reqTrsTrainingTestData = (dict)=> requests(
    {   
        url:`/api/api_trs_training_and_test_record/${dict["myDateS"]}/${dict["myDateE"]}/${dict["mySystem"]}/${dict["category"]}/${dict["EmployeeID"]}/${dict["courseName"]}/${dict["pageNum"]}/`,
        method:'get',
        data:dict,
    }
);


export const reqCsodTrainingTestData = (dict)=> requests(
    {   
        url:`/api/api_csod_training_and_test_record/${dict["myDateS"]}/${dict["myDateE"]}/${dict["mySystem"]}/${dict["category"]}/${dict["EmployeeID"]}/${dict["courseName"]}/${dict["pageNum"]}/`,
        method:'get',
        data:dict,
    }
);

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

SpringCloud Alibaba入门4之nacos注册中心管理

我们在上一章的基础上进行学习。https://blog.csdn.net/qinxun2008081/article/details/131330451 什么是注册中心?它记录了服务和服务地址的映射关系。在分布式架构中&#xff0c;服务会注册到这里&#xff0c;当服务需要调用其它服务时&#xff0c;就到这里找到服务的地址&…

Java开发必看,Spring增强性能与现代应用支持

出品 | CSDN 云计算 开发界经典话题之一&#xff0c;就是语言之争。除了每月的开发语言排行榜上几大王牌语言在榜单前列上上下下&#xff0c;在 CSDN 连续几年的年度开发者调研《中国开发者调查报告》中&#xff0c;Java 一直被评为开发者使用占比最高的语言&#xff0c;而 Spr…

银河麒麟V10 wireguard 编译

系统信息 操作系统信息&#xff1a; 我这里使用的操作系统是 银河麒麟V10&#xff0c;CPU为飞腾 ARM64 根据wireguard 的编译指南&#xff1a;https://www.wireguard.com/compilation/ 安装 编译安装内核 注意&#xff1a;5.6 以上内核不需要编译安装&#xff0c;已经集…

【数据库五】MySQL高级SQL语句

MySQL高级SQL语句 1.MySQL进阶查询1.1 select1.2 distinct1.3 where1.4 and or1.5 in1.6 between1.7 通配符1.8 like 2.MySQL数据库函数2.1 数学函数2.2 聚合函数2.3 字符串函数 3.查询函数3.1 order by3.2 group by3.3 sql语句执行顺序3.4 having3.5 别名&#xff08;字段别名…

【剑指offer专项突破版】队列篇——“C“

文章目录 前言一、滑动窗口的平均值题目分析思路分析对列代码题解代码 二、最近请求次数题目分析思路分析队列代码题解代码 三、往完全二叉树添加节点题目分析思路分析队列与接口代码题解代码 四、二叉树每层的最大值题目分析思路分析队列代码题解代码 五、二叉树最底层最左边的…

学习 WooCommerce REST API

主要学习这个技术文档即可 WooCommerce REST API 技术文档 WooCommerce 官方文档 github : woocommerce/woocommerce 以下设置以及测试代码&#xff0c;都来自 WooCommerce REST API 技术文档 设置 REST API 设置 – 固定链接 &#xff08;Settings > Permalinks.&#…

MySQL - 第4节 - MySQL数据类型

目录 1.数据类型的作用 2.数据类型分类 3.数值类型 3.1.tinyint类型 3.2.bit类型 3.3.float类型 3.4.decimal类型 4.字符串类型 4.1.char类型 4.2.varchar类型 4.3.char和varchar比较 5.时间日期类型 6.enum和set类型 6.1.enum和set类型 6.2.调查表案例 6.3.通…

二手车交易APP开发功能有哪些?

二手车交易APP开发功能有哪些&#xff1f; 1、车辆估价&#xff1a;在选购二手车时&#xff0c;了解车辆的市场价值是非常重要的。为了保证客户能够准确估计车辆的价值&#xff0c;二手车APP软件开发应该具备车辆估价功能。用户可以通过APP输入车辆的基本信息&#xff0…

离线(内网)主机创建python项目运行环境

一、创建requirements.txt文件 文件中是python项目需要的依赖和版本号 二、把依赖下载到本地 准备一个能联网的pc&#xff0c;把依赖下载到本地 pip download -d ./venv -r requirements.txt -i https://pypi.mirrors.ustc.edu.cn/simple/这个命令会把依赖下载到venv文件夹…

指数全线收跌,上证跌破3200点,仅4137只个股下跌!

如题&#xff0c;端午假期前一天&#xff0c;A股指数全线收跌&#xff0c;上证指数跌破3200点&#xff0c;仅4137只个股下跌&#xff01;就问你服不服&#xff1f; 不要急&#xff0c;不要慌&#xff0c;我们来细细分析。 过去一两周&#xff0c;上证指数以震荡为主&#xff…

嵌入式Linux学习入门

大四毕业了&#xff0c;签了一份嵌入式开发的工作&#xff0c;现在准备入门了&#xff0c;搜集一些要学习的内容。 嵌入式开发学习路线 51单片机&#xff0c;arm&#xff0c;stm32在单片机上 在单片机上编程c语言和在嵌入式系统写c语言&#xff0c;有很大不同 gcc又与我们普…

与反恐、反间谍科同级,美国国家安全部设立网络安全科

美国国家安全部&#xff08;NSD&#xff09;成立了一个新的网络部门&#xff0c;旨在能够更有力地应对高技术性的网络威胁。 这个新成立的部门&#xff0c;正式名称为国家网络安全科&#xff0c;是为了响应美国司法部 &#xff08;DoJ&#xff09; 2022 年全面网络审查中的核心…

导致JVM内存泄露的ThreadLocal详解

很常见的关于ThreadLocal的面试题的问法&#xff1a; 1.说说你对ThreadLocal的理解。 2.ThreadLocal 是什么&#xff1f;有哪 些使用场景&#xff1f;什么是线程局部变量&#xff1f; 3.ThreadLocal内存泄漏分析与解决方案。 ps:想理解好ThreadLocal&#xff0c;必须先得理…

Spring Boot命令行启动添加参数

一、Spring Boot命令行三种参数形式 通过java -jar启动springboot的jar项目时&#xff0c;可以动态传递参数来进行配置和开发&#xff0c;比如 java -jar xxx.jar --server.port8081 可以通过server.port修改项目启动的端口&#xff0c;通过命令行传递的参数具有更高的优先级…

华为OD机试 JavaScript 实现【最优策略组合下的总的系统消耗资源数】【牛客练习题】,附详细解题思路

一、题目描述 在通信系统中有一个常见的问题是对用户进行不同策略的调度&#xff0c;会得到不同系统消耗的性能。 假设由N个待串行用户&#xff0c;每个用户可以使用A/B/C三种不同的调度策略&#xff0c;不同的策略会消耗不同的系统资源。 请你根据如下规则进行用户调度&…

【Java-SpringBoot+Vue+MySql】Day3.2-RESTful风格

目录 一、RESTful风格介绍 1、知识轰炸 2、代码演练 &#xff08;1&#xff09;测试get接口 &#xff08;2&#xff09;测试Post接口 &#xff08;3&#xff09;测试Put接口 &#xff08;4&#xff09;测试delete接口 二、Swagger介绍 1、知识轰炸 2、实操演练 &#x…

Android修行手册-多路USB外接摄像头

点击跳转>Unity3D特效百例点击跳转>案例项目实战源码点击跳转>游戏脚本-辅助自动化点击跳转>Android控件全解手册点击跳转>Scratch编程案例点击跳转>软考全系列 &#x1f449;关于作者 专注于Android/Unity和各种游戏开发技巧&#xff0c;以及各种资源分享&…

CSS3-盒子模型

盒子模型的介绍 盒子概念 盒子组成 盒子内减 拓展 1. 盒子的概念 1 页面中的每一个标签&#xff0c;都可看做是一个 “盒子”&#xff0c;通过盒子的视角更方便的进行布局 2 浏览器在渲染&#xff08;显示&#xff09;网页时&#xff0c;会将网页中的元素看做是一个个的矩形区域…

Selenium详解

Selenium 环境配置好之后&#xff0c;我们就可以使用 Selenium 来操作浏览器&#xff0c;做一些我们想做的事情了。在我们爬取网页过程中&#xff0c;经常发现我们想要获得的数据并不能简单的通过解析 HTML 代码获取&#xff0c;这些数据是通过 AJAX 异步加载方式或经过 JS 渲染…

Python高级系列教程:Python闭包和装饰器

今天我们将继续讲解 Python 中的闭包和装饰器。虽然我们还没有详细学习这两个概念&#xff0c;但在面向对象编程中&#xff0c;我们已经经常使用装饰器了。装饰器可以给函数增加额外的功能&#xff0c;就像语法糖一样甜。在 Python 中&#xff0c;装饰器的格式通常是在函数上方…