【无标题】jenkins消息模板(飞书)

这里写目录标题

    • Jenkins 安装的插件
  • 发送消息到飞书
    • 预览 1 (单Job)
    • 预览 2 (多Job,概览)

Jenkins 安装的插件

插件名称作用
Rebuilder
  1. Rebuilder。
    官方地址:https://plugins.jenkins.io/rebuild
    安装方式:在Jenkins插件当中直接搜索即可安装。
    功能说明:此插件可以直接重复上次构建,也可以用于查看一些参数比较复杂的构建时,上次构建所选的参数是什么。非常nice的一个插件。

  2. AnsiColor。
    官方地址:https://plugins.jenkins.io/ansicolor
    安装方式:在Jenkins插件当中直接搜索即可安装。
    功能说明:扩展支持我们在shell当中定义的echo -e指令,从而给一定的输出上颜色。
    使用方式:点此跳转到使用介绍。(opens new window)

  3. Maven Release Plug-in。
    maven风格插件。
    安装方式:在Jenkins插件当中直接搜索即可安装。

  4. user build vars。
    官方地址:https://wiki.jenkins.io/display/JENKINS/Build+User+Vars+Plugin
    安装方式:在Jenkins插件当中直接搜索即可安装。
    功能说明:通过此插件,让整个Jenkins系统中的用户参数成为一个可调用的变量。
    使用方式:在构建环境中选中Set Jenkins user build variables。

  5. Post build task
    功能说明:此功能允许您关联 shell 或批处理脚本,这些脚本根据构建日志输出在 Hudson
    上执行某些任务。如果日志文本与构建日志文件中的某处匹配,脚本将执行。例如:如果在日志文本中指定了“IOException”,并且构建日志文件包含字符串“IOException”,则脚本将执行。
    允许使用 Java 正则表达式,并且可以将组用作脚本参数。如果文本是“Last Build : #(\d+)”并且脚本是“script.sh”,那么如果日志包含一行“Last
    Build : #4”,脚本“script.sh 4”将被调用.

  6. MultiJob Phase
    功能说明:上下游执行

发送消息到飞书

预览 1 (单Job)

在这里插入图片描述

  • 对应shell
#!/usr/bin/env bash
url1="https://open.feishu.cn/open-apis/bot/v2/hook/" 
url2="https://open.feishu.cn/open-apis/bot/v2/hook/" #  1. 消息 接收地址
webhook_list=($url1 $url2)# ========================
#  2. 消息 参数预处理
if [ ! "$GIT_BRANCH" ]; thenecho "----------------- GIT_BRANCH 为空"GIT_BRANCH="''"
fi
echo -e "GIT_BRANCH -> ${GIT_BRANCH}"
# ========================
#  3. 消息 执行发送
run_send_msg() {echo -e "\n 复制发送消息脚本 $HOME -> ${WORKSPACE}" && cp "$HOME"/send_msg_to_feishu.py "${WORKSPACE}"for ((i = 0; i < ${#webhook_list[@]}; i++)); dowebhook=${webhook_list[$i]}echo -e "发送中 --> $webhook"python3 send_msg_to_feishu.py "${webhook}" -job_name "${JOB_NAME}" -job_url "${JOB_URL}" -build_name "${BUILD_ID}" -branch "${GIT_BRANCH}"doneecho -e "发送完成 \n\n"
}run_send_msg
  • 对应python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import json
import timeimport requestsparser = argparse.ArgumentParser(description='Jenkins 发送消息到飞书',epilog="执行示例>>> python ${webhook} -job_name ${JOB_NAME} -job_url ${JOB_URL} -branch ${GIT_BRANCH} -build_name ${BUILD_NUMBER}  ")
parser.add_argument('webhook', help='机器人webhookURL')  # 必填
parser.add_argument('-job_name', '--JOB_NAME', help='作业Name', )  # 选填
parser.add_argument('-job_url', '--JOB_URL', help='作业URL', required=True, )  # 必填
parser.add_argument('-branch', '--GIT_BRANCH', help='git分支', default='')  # 选填
parser.add_argument('-build_name', '--BUILD_DISPLAY_NAME', help='编译Name')  # 选填
# parser.add_argument('-build_url', '--BUILD_URL', help='编译URL', required=True, )  # 必填webhook = parser.parse_args().webhook
JOB_NAME = parser.parse_args().JOB_NAME
JOB_URL = parser.parse_args().JOB_URL
GIT_BRANCH = parser.parse_args().GIT_BRANCH
BUILD_DISPLAY_NAME = parser.parse_args().BUILD_DISPLAY_NAME
# BUILD_URL = parser.parse_args().BUILD_URLBUILD_URL = JOB_URL + '/lastBuild'def set_msg():# ============ 数据获取 ============result = requests.get(f'{BUILD_URL}/api/json', auth=jenkins_auth).json()# print(BUILD_STATUS.request.url)try:shortDescription = result['actions'][0]['causes'][0]['shortDescription']  # 启动者except KeyError:  # 安装 `Multijob plugin` 后位置变更shortDescription = result['actions'][1]['causes'][0]['shortDescription']  # 启动者print(result['timestamp'])timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(result['timestamp'] / 1000))  # 编译开始时间print(timestamp)BUILD_STATUS = result['result']  # 编译状态print('build_status --> ', BUILD_STATUS)duration = result['duration']  # 编译持续时间build_duration = int(duration) // 1000  # 毫秒到秒minutes, seconds = divmod(build_duration, 60)hours, minutes = divmod(minutes, 60)print(f'build duration --> {hours}H:{minutes}M:{seconds}S')# ============ 设置样式 ============if "SUCCESS" in BUILD_STATUS:  # 成功template_color = "green"elif "FAILURE" in BUILD_STATUS:  # 失败template_color = "red"elif "ABORTED" in BUILD_STATUS:  # 终止template_color = "yellow"else:template_color = "grey"# ============ 卡片模板 ============card = json.dumps({"config": {"wide_screen_mode": True},"elements": [{"tag": "markdown","content": f"触发时间:{timestamp}\n"f"分支名称:{GIT_BRANCH}\n"f"构建编号:{BUILD_DISPLAY_NAME}\n"f"构建状态:<font color={template_color}>{BUILD_STATUS}</font>\n"},{"tag": "note","elements": [{"tag": "img","img_key": f"{img_icon}","alt": {"tag": "plain_text","content": f"{JOB_URL}"}},{"tag": "plain_text","content": f"{shortDescription}"}]},{"tag": "hr"},{"tag": "action","actions": [{"tag": "button","text": {"tag": "plain_text","content": "报告链接"},"type": "primary","multi_url": {"url": f"{BUILD_URL}/allure","pc_url": "","android_url": "","ios_url": ""}}],"layout": "bisected"}],"header": {"template": f"{template_color}","title": {"content": f"作业名称: {JOB_NAME}","tag": "plain_text"}}})body = json.dumps({"msg_type": "interactive", "card": card})headers = {"Content-Type": "application/json"}res = requests.post(url=webhook, data=body, headers=headers)print(res.text)if __name__ == '__main__':img_icon = 'img_v2_098e80ae-e583-4148-b822-xxxxxx'  # img_key_id jenkinsIconjenkins_auth = ('report', 'report')  # jenkins User:Pwdset_msg()

预览 2 (多Job,概览)

Jenkins 需安装Multijob插件
Multijob https://plugins.jenkins.io/jenkins-multijob-plugin/

在这里插入图片描述

  • 对应shell
#!/usr/bin/env bashecho -e "\n\n 消息处理"
# ========================
#  消息发送
# ========================#  1. 消息 接收地址
# -----------------------
group='https://open.feishu.cn/open-apis/bot/v2/hook/'webhook_list=($group)
py_send='SendMsgFeishu.py'# ========================
#  2. 文件处理
# -----------------------
echo -e "\n 复制发送消息脚本 $HOME -> ${WORKSPACE}" && cp "$HOME"/$py_send "${WORKSPACE}"# ========================
#  3. 消息 执行发送
# -----------------------
run_send_msg() {for ((i = 0; i < ${#webhook_list[@]}; i++)); dowebhook=${webhook_list[$i]}echo -e "发送中 --> $webhook"python3 $py_send "${webhook}" -job_url "${JOB_URL}"doneecho -e "发送完成 \n\n"
}run_send_msg
  • 对应python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import datetime
import json
import subprocess
import time
from json import JSONDecodeErrorimport requestsparser = argparse.ArgumentParser(description='Jenkins 发送消息到飞书',epilog="执行示例>>> python ${webhook} -job_url ${JOB_URL}")
parser.add_argument('webhook', help='机器人webhookURL')  # 必填
parser.add_argument('-job_url', '--JOB_URL', help='作业URL', required=True, )  # 必填webhook = parser.parse_args().webhook
JOB_URL = parser.parse_args().JOB_URL
BUILD_URL = JOB_URL + '/lastBuild'job_name = []  # 运行名称
job_duration = []  # 运行时长
job_status = []  # 运行状态
job_url = []  # 运行结果
pass_rate = []  # 百分比显示print('修改时间:2023-07-04 10:02:43')def get_base_info():device_id = subprocess.getoutput('cat /etc/ding_issue')version_os = subprocess.getoutput('cat /etc/issue')version_browser = subprocess.getoutput('dingdao-dingtao-stable -version')device_sn = subprocess.getoutput('hostname').split('-')[-1]# print(deviceid,os_version,browser_version, sn)return device_id, version_os, version_browser, device_sndef sending_alarms(text=None):local_network_info = subprocess.getoutput("networkctl status")if text is None:text = f"网络异常: 无法访问\n{BUILD_URL}\n{local_network_info}"payload_message = {"msg_type": "text", "content": {"text": text}}headers = {"Content-Type": "application/json"}res = requests.post(url=webhook, data=json.dumps(payload_message), headers=headers)print(f"告警信息发送状态:{res.text}")def set_msg():get_result = requests.get(f'{BUILD_URL}/api/json', auth=jenkins_auth)# ------------------# ------ 数据获取 ------# ------------------JENKINS_URL = BUILD_URL.split('job')[0]  # JENKINS_URL# ------ begin 登陆异常 ------try:print(f"查询地址:{get_result.url}")result = get_result.json()# except JSONDecodeError:  # json解析失败 未登陆#     text = "Error 401 Unauthorized"#     sending_alarms(text)#     quit(text)# except RecursionError:  # BUG: https://github.com/jenkinsci/tikal-multijob-plugin/issues/255#     quit('递归错误:从 unicode 字符串解码 JSON 对象时超出最大递归深度')except OSError:  # 异常列表: 网络text = "No route to host"sending_alarms()quit(text)except Exception as e:  # 通用异常处理text = f"发生异常: {type(e).__name__} --> {str(e)}\n检查:{get_result.url}"sending_alarms(text)quit(text)# res = requests.get(f'{BUILD_URL}/api/json', auth=jenkins_auth)# if res.status_code == 401:#     quit('Error 401 Unauthorized')# else:#     result = res.json()# # ------ end 登陆异常 ------shortDescription = result['actions'][0]['causes'][0]['shortDescription']  # 启动者timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(result['timestamp'] / 1000))  # 编译开始时间# ------ begin 获取持续时间 ------if result['duration'] != 0:  # 获取字段duration = int(result['duration']) // 1000  # 编译持续时间minutes, seconds = divmod(duration, 60)hours, minutes = divmod(minutes, 60)build_duration = f'{hours}h {minutes}m {seconds}s'print(f"--> 通过响应值换算{build_duration}\n")else:  # 通过当前时间计算build_duration = datetime.datetime.now() - datetime.datetime.fromtimestamp(result['timestamp'] / 1000)build_duration = str(build_duration).split('.')[0]print(f"--> 通过当前时间计算耗时{build_duration}\n")# ------ end 获取持续时间 ------total_count = len(result['subBuilds'])  # 数量总计print(f'======= 项目概览 ======= \n'f'shortDescription:{shortDescription}\nbuild duration:{build_duration}\ntotal_count:{total_count}\ntimestamp:{timestamp}\n')print('提示: 没有allure就报错 无法运行 JSONDecodeError')for index in result['subBuilds']:  # 提取数据# print(index)# print(index['result'])# 数据预处理allure_summary = requests.get(f"{JENKINS_URL}{index['url']}/allure/widgets/summary.json").json()['statistic']allure_history_trend = requests.get(f"{JENKINS_URL}{index['url']}/allure/widgets/history-trend.json")# print(allure_history_trend.request.url)try:  # 获取历史数据allure_history_trend = allure_history_trend.json()[1]except IndexError:print('没有历史数据')allure_history_trend = allure_history_trend.json()[0]# 计算百分比if allure_summary['total'] != 0:  # 除数不能为0allure_pass_rate = allure_summary['passed'] / allure_summary['total']else:allure_pass_rate = 0  # 除数不能为0if allure_history_trend['data']['total'] != 0:allure_history = allure_history_trend['data']['passed'] / allure_history_trend['data']['total']else:allure_history = 0# ------------------# ------ 设置样式 ------# ------------------if "SUCCESS" == index['result']:  # 成功color = "green"elif "FAILURE" == index['result']:  # 失败color = "red"elif "ABORTED" == index['result']:  # 中止color = "yellow"else:  # 其他color = "grey"# 通过率对比allure_change = allure_pass_rate - allure_historyprint(f"{index['jobName']} --> 本次比上次通过率 {allure_change}")if allure_pass_rate > allure_history:allure_pass_rate = f'<font color=green>↑{allure_pass_rate:.2%}</font>'elif allure_pass_rate < allure_history or allure_pass_rate == 0:allure_pass_rate = f'<font color=red>↓{allure_pass_rate:.2%}</font>'else:allure_pass_rate = f' {allure_pass_rate:.2%}'# ------------------# ------ 载入数据 ------# ------------------job_name.append({"tag": "markdown", "content": f"{index['jobName']}", "text_align": "center"})job_duration.append({"tag": "markdown", "content": f"{index['duration']}", "text_align": "center"})job_status.append({"tag": "markdown", "content": f"<font color={color}>{index['result']}</font>", "text_align": "center"})job_url.append({"tag": "markdown", "content": f"[查看]({JENKINS_URL}{index['url']}/allure)", "text_align": "center"})pass_rate.append({"tag": "markdown","content": f"{allure_summary['passed']}/{allure_summary['total']}{allure_pass_rate} ","text_align": "center"})print(f'======= 项目详情 ======= \n{job_name}\n{job_duration}\n{job_status}\n{pass_rate}\n{job_url}\n')def set_msg_a(total_count=None, build_duration=None, timestamp=None, shortDescription=None):"""# ------------------# ------ 卡片模板 ------# ------------------total_count: 总数量build_duration: 持续时间timestamp: 开始时间shortDescription: 启动者"""card = json.dumps({"elements": [{"tag": "markdown","content": "**项目总览**\n"},{"tag": "column_set","flex_mode": "bisect","background_style": "grey","horizontal_spacing": "default","columns": [{"tag": "column","width": "weighted","weight": 1,"elements": [{"tag": "markdown","text_align": "center","content": f"项目数量\n**{total_count}**\n"}]},{"tag": "column","width": "weighted","weight": 1,"elements": [{"tag": "markdown","text_align": "center","content": f"运行耗时\n**{build_duration}**"}]},{"tag": "column","width": "weighted","weight": 1,"elements": [{"tag": "markdown","text_align": "center","content": f"执行时间\n**{timestamp}**\n"}]}]},{"tag": "markdown","content": "**项目信息**"},{"tag": "column_set","flex_mode": "none","background_style": "grey","columns": [{"tag": "column","width": "weighted","weight": 2,"vertical_align": "top","elements": [{"tag": "markdown","content": "**项目名**","text_align": "center"}]},{"tag": "column","width": "weighted","weight": 1,"vertical_align": "top","elements": [{"tag": "markdown","content": "**运行时长**","text_align": "center"}]},{"tag": "column","width": "weighted","weight": 1,"vertical_align": "top","elements": [{"tag": "markdown","content": "**运行状态**","text_align": "center"}]},{"tag": "column","width": "weighted","weight": 1,"vertical_align": "top","elements": [{"tag": "markdown","content": "**passed/total/通过率**","text_align": "center"}]},{"tag": "column","width": "weighted","weight": 1,"vertical_align": "top","elements": [{"tag": "markdown","content": "**Report**","text_align": "center"}]}]},{"tag": "column_set","flex_mode": "none","background_style": "default","columns": [{"tag": "column","width": "weighted","weight": 2,"vertical_align": "top","elements": job_name},{"tag": "column","width": "weighted","weight": 1,"vertical_align": "center","elements": job_duration},{"tag": "column","width": "weighted","weight": 1,"vertical_align": "top","elements": job_status},{"tag": "column","width": "weighted","weight": 1,"vertical_align": "top","elements": pass_rate},{"tag": "column","width": "weighted","weight": 1,"vertical_align": "top","elements": job_url}]},{"tag": "hr"},{"tag": "note","elements": [{"tag": "img","img_key": f"{img_icon}","alt": {"tag": "plain_text","content": ""}},{"tag": "plain_text","content": f"{shortDescription}\n颜色代表对比上次执行,绿色上升,红色下降"}]}]})card_id = json.dumps({"type": "template","data": {"template_id": "ctp_AA6DZMfkJekh",  # 卡片id,参数必填。可在搭建工具中通过“复制卡片ID”获取"template_variable":  # 卡片中绑定的变量的取值。如没有绑定变量,可不填此字段。{"total_count": "29","group_table": [{"jobName": "test001","duration": "小于1小时","build_url": "baidu.com","build_status": "SUCCESS","tmp_color": "green"},{"jobName": "test002","duration": "2小时","build_url": "baidu.com","build_status": "FAILURE","tmp_color": "red"},{"jobName": "test003","duration": "3小时","build_url": "baidu.com","build_status": "ABORTED","tmp_color": "yellow"},{"jobName": "test004","duration": "3小时","build_url": "baidu.com","build_status": "UNSTABLE","tmp_color": "grey"}],"duration": "15080","shortDescription": "Started by user admin","timestamp": "1686645721264","jobName": "","tmp_color": ""}}})body = json.dumps({"msg_type": "interactive", "card": card})  # 使用 当前模板# body = json.dumps({"msg_type": "interactive", "card": card_id})  # 使用 预置模板headers = {"Content-Type": "application/json"}res = requests.post(url=webhook, data=body, headers=headers)print(f'消息发送响应 -->\n\t {res.text}')if __name__ == '__main__':img_icon = 'img_v2_098e80ae-e583-4148-b822-f42a05298d3g'  # img_key_id jenkinsIconjenkins_auth = ('result', 'result')  # jenkins User:Pwd# get_base_info()set_msg()deviceid, os_version, browser_version, sn = get_base_info()print(deviceid, os_version, browser_version, sn)

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

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

相关文章

leetcode1475. 商品折扣后的最终价格 【单调栈】

简单题 第一次错误做法 class Solution { public:vector<int> finalPrices(vector<int>& prices) {int n prices.size();stack<int> st;unordered_map<int, int> mp;int i 0;while(i ! prices.size()) {int t prices[i];if (st.empty() || t …

适应高速率网络设备的-2.5G/5G/10G网络变压器/网络滤波器介绍

Hqst盈盛&#xff08;华强盛&#xff09;电子导读&#xff1a;在高速发展的互联网/物联网时代&#xff0c;为满足高网速的网络数据传输需求&#xff0c;网络设备在制造中也要选用合适的网络变压器/滤波器产品&#xff0c;有哪些可供选择的高速率网络变压器产品也是广大采购人员…

C++初学者学习指南

文章目录 环境职业选择基本技能新特性与学习曲线高阶技能C模版元编程线程池&#xff0c;异步任务 C 相关工具及资源C ToolsC Resources 项目大项目小项目 如何学未来期望 环境 编程工具&#xff1a;VSCode插件&#xff1a; BazelC/CClang-FormatVim 职业选择 AI领域&#xf…

如何将多个网页合并成一个PDF文件?

pdfFactory是一款PDF虚拟打印软件&#xff0c;但与其他虚拟打印机软件不同的是&#xff0c;它使用起来更加简单高效。由于无需Acrobat就能生成Adobe PDF文件&#xff0c;它可以帮助用户在系统没有连接打印机的情况下&#xff0c;将大部分支持打印的文档资料迅速转换成PDF文件&a…

SOPC之NIOS Ⅱ实现电机转速PID控制(调用中断函数)

通过FPGA开发板上的NIOS Ⅱ搭建电机控制的硬件平台&#xff0c;包括电机正反转、编码器的读取&#xff0c;再通过软件部分实现PID算法对电机速度进行控制&#xff0c;使其能够渐近设定的编码器目标值。 一、问题与改进 SOPC之NIOS Ⅱ实现电机转速PID控制_STATEABC的博客-CSDN…

DevOps团队如何提高Kubernetes性能

今天&#xff0c;Kubernetes仍然是开发人员最需要的容器。Kubernets最初由 Google 工程师开发&#xff0c;作为跨本地、公共云、私有云或混合云托管的首选解决方案享誉全球。 来自Statista的报告显示&#xff0c;公共云中的Kubernetes市场份额在过去一年中上升了近30%。并且在…

C#_GDI+ 绘图编程入门

官网提供相关API GDI 基本图形功能_drawing 高级二维和矢量图形功能_drawing2D GDI 图像处理功能_Imaging GDI 排版功能_text Windows 窗体应用程序提供打印功能_Printing 像素 构成图像的最小单位就是像素&#xff1b;屏幕上显示不管是位图或者矢量图&#xff0c;当描述…

【80天学习完《深入理解计算机系统》】第十一天 3.4 跳转指令

专注 效率 记忆 预习 笔记 复习 做题 欢迎观看我的博客&#xff0c;如有问题交流&#xff0c;欢迎评论区留言&#xff0c;一定尽快回复&#xff01;&#xff08;大家可以去看我的专栏&#xff0c;是所有文章的目录&#xff09;   文章字体风格&#xff1a; 红色文字表示&#…

学习ts(九)混入

对象混入 使用Object.assign()进行对象混入&#xff0c;最后的people会被识别为三种类型的联合类型 类混入 使用implement并非extnds实现混入。 属性在混入类里面定义&#xff0c;分别在类中占位&#xff0c;方法分别在类中定义&#xff0c;在混合类中占位。这告诉编译器这…

小程序如何手动变更会员卡等级

有时候需要商家手动变更会员卡等级&#xff0c;以让会员获取更多的福利和特权。下面就介绍一些小程序手动变更会员卡等级的常见方法和策略。 1. 找到指定的会员卡。在管理员后台->会员管理处&#xff0c;找到需要更改等级的会员卡。也支持对会员卡按卡号、手机号和等级进行…

22.查找,线性表的查找

目录 一. 查找的基本概念 二. 线性表的查找 &#xff08;1&#xff09;顺序查找&#xff08;线性查找) &#xff08;2&#xff09;折半查找&#xff08;二分或对分查找&#xff09; &#xff08;3&#xff09;分块查找 一. 查找的基本概念 查找表是由同一类型的数据元素(…

macbookpro如何清理系统数据 macbookpro怎么删除软件

Macbook Pro是苹果公司的一款高性能笔记本电脑&#xff0c;它拥有强大的硬件和流畅的操作系统。然而&#xff0c;随着时间的推移&#xff0c;你可能会发现你的Macbook Pro变得越来越慢&#xff0c;储存空间也越来越紧张。这时候&#xff0c;你需要对你的Macbook Pro进行一些清理…

【Java从0到1学习】11 Java集合框架

1. Collection 1.1 Java类中集合的关系图 1.2 集合类概述 在程序中可以通过数组来保存多个对象&#xff0c;但在某些情况下开发人员无法预先确定需要保存对象的个数&#xff0c;此时数组将不再适用&#xff0c;因为数组的长度不可变。例如&#xff0c;要保存一个学校的学生信…

Redis 为什么这么快?

前言 作为一名后端软件工程师&#xff0c;工作中你肯定和 Redis 打过交道。但是Redis 为什么快呢&#xff1f;很多人只能答出Redis 因为它是基于内存实现的&#xff0c;但是对于其它原因都是模棱两可。 那么今天就一起来看看是Redis 为什么快吧&#xff1a; Redis 为什么这么快…

vue与vueComponent的关系

创建完组件之后 就会创建一个vueComponent构造函数 当注册成功这个组件并且在页面使用之后 就会创建一个vueComponent实例对象&#xff0c; 所以为了避免组件在使用过程中data对象中的值混乱 组件中的data要写成函数&#xff0c; 使得每次创建的组件实例对象都可以返回一…

批量爬虫采集大数据的技巧和策略分享

目录 1. 使用多线程或异步编程&#xff1a; 2. 设置适当的请求频率&#xff1a; 3. 使用代理服务器&#xff1a; 4. 处理异常和错误&#xff1a; 5. 监控和管理任务队列&#xff1a; 6. 数据存储和处理&#xff1a; 7. 随机化请求参数和头信息&#xff1a; 8. 定时任务…

前端组件库造轮子——Input组件开发教程

前端组件库造轮子——Input组件开发教程 前言 本系列旨在记录前端组件库开发经验&#xff0c;我们的组件库项目目前已在Github开源&#xff0c;下面是项目的部分组件。文章会详细介绍一些造组件库轮子的技巧并且最后会给出完整的演示demo。 文章旨在总结经验&#xff0c;开源…

大数据风控介绍

众所周知&#xff0c;金融是数据化程度最高的行业之一&#xff0c;也是人工智能和大数据技术重要的应用领域。随着大数据收集、存储、分析和模型技术日益成熟&#xff0c;大数据技术逐渐应用到金融风控的各个环节。个推作为专业的数据智能服务商&#xff0c;拥有海量数据资源&a…

3D姿态相关的损失函数

loss_mpjpe: 计算预测3D关键点与真值之间的平均距离误差(MPJPE)。 loss_n_mpjpe: 计算去除尺度后预测3D关键点误差(N-MPJPE),评估结构误差。 loss_velocity: 计算3D关键点的速度/移动的误差,评估运动的平滑程度。 loss_limb_var: 计算肢体长度的方差,引导生成合理的肢体长度…

【C++】C++ 引用详解 ⑤ ( 函数 “ 引用类型返回值 “ 当左值被赋值 )

文章目录 一、函数返回值不能是 " 局部变量 " 的引用或指针1、函数返回值常用用法2、分析函数 " 普通返回值 " 做左值的情况3、分析函数 " 引用返回值 " 做左值的情况 函数返回值 能作为 左值 , 是很重要的概念 , 这是实现 " 链式编程 &quo…