react 网页/app复制分享链接到剪切板,分享到国外各大社交平台,通过WhatsApp方式分享以及SMS短信方式分享链接内容

1.需求 

最近在做一个国际网站app,需要把app中某个页面的图文链接分享到国外各大社交平台上(facebook,whatapp,telegram,twitter等),以及通过WhatApp聊天方式分享,和SMS短信方式分享链接内容,该怎么做呢?图示如下:

分享到国外各大社交平台: 

操作说明:

        当点击COPY URL时,复制分享链接到剪切板,然后点击各个分享平台图标,调用分享apk或者方法,从而调起社交平台app或者对应的web网页 ,进行分享操作

通过WhatApp方式,SMS方式分享: 

 操作说明:

        1.WhatsAPP分享:

                程序生成随机电话号码,默认选中第一个电话号码,点击WhatsAPP后,调取WhatApp相关方法接口,进行分享操作,然后电话号码变灰,当再次点击WhatsAPP时,触发下一个电话号码操作,图示如下:

        2.SMS方式分享

                点击SMS按钮时,触发SMS接口请求,调用SMS相关url进行分享操作

2.实现分享到国外各大社交平台

先上代码,通过点击 COPY URL 复制分享链接到剪切板,然后点击各个平台图标,实现分享操作

COPY URL,点击平台图标相关代码: 

import React, {useState} from "react";
import axios from "axios";
import Scroll from "../../components/Scroll";
import {CountDown, Steps, Tabs, Toast, Popup, Cell, Dialog, Swiper, NoticeBar, Image} from "react-vant";
import {CopyToClipboard} from "react-copy-to-clipboard";const Index = () => {//分享url:拼接要分享的页面url,以及带上参数//注意:这里参数有的分享平台不支持?格式,可以使用简化格式,eg:http:www.test.com/target_page/100/paramconst GetUrl = (tagId) => {return `${window.location.origin}/target_page?param=${tagId}`;};//各个分享平台对应的urlconst GetWhatsAppUrl = (tagId) => {//也可以用这个`https://api.whatsapp.com/send?text=` + encodeURIComponent("test") + encodeURIComponent("\n\n" + GetInviteWheelUrl(tagId));return encodeURI(`whatsapp://send?text=test\n${GetUrl(tagId)}`);
};const GetTelegramUrl = (tagId, text) => {return encodeURI("https://t.me/share/url?url=" + encodeURIComponent(GetInviteWheelUrl(tagId)) + "&text=" + encodeURIComponent(text));};const GetTwitterUrl = (tagId, text) => {return encodeURI("https://twitter.com/intent/tweet?text=" + encodeURIComponent(text) + "&url=" + encodeURIComponent(GetInviteWheelUrl(tagId)));};const GetFacebookUrl = (tagId, text) => {return "https://www.facebook.com/sharer/sharer.php?u=" + encodeURIComponent(GetUrl(tagId)) + "&t=" + encodeURIComponent(text)};//分享到社交软件const shareFriend = (type) => {let shareText = "分享说明" ;switch (type) {case "facebook":if (window.document) {if (window.document.getElementById("og_url")) {window.document.getElementById("og_url").content=GetUrl(rid);}if (window.document.getElementById("og_description")) {window.document.getElementById("og_description").content=shareText;}if (window.document.getElementById("og_title")) {window.document.getElementById("og_title").content=shareText;}if (window.document.getElementById("og_image")) {window.document.getElementById("og_image").content=window.location.origin + "../images/banner_x2.png";}}window.location.href = GetFacebookUrl(tagId, shareText);return;case "whatApp":if (window.document) {if (window.document.getElementById("og_url")) {window.document.getElementById("og_url").content=GetUrl(tagId);}if (window.document.getElementById("og_description")) {window.document.getElementById("og_description").content=shareText;}if (window.document.getElementById("og_title")) {window.document.getElementById("og_title").content=shareText;}if (window.document.getElementById("og_image")) {window.document.getElementById("og_image").content=window.location.origin + "../images/banner_x2.png";}}window.location.href = GetWhatsAppUrl(tagId, shareText);return;case "telegram":window.location.href = GetTelegramUrl(tagId, shareText);return;case "twitter":if (window.document) {if (window.document.getElementById("tw_description")) {window.document.getElementById("tw_description").content=shareText;}if (window.document.getElementById("tw_title")) {window.document.getElementById("tw_title").content=shareText;}if (window.document.getElementById("tw_card")) {window.document.getElementById("tw_card").content=window.location.origin + "../images/banner_x2.png";}if (window.document.getElementById("tw_card")) {window.document.getElementById("tw_card").content=window.location.origin + "../images/banner_x2.png";}if (window.document.getElementById("tw_image")) {window.document.getElementById("tw_image").content=window.location.origin + "../images/banner_x2.png";}if (window.document.getElementById("tw_url")) {window.document.getElementById("tw_url").content=GetUrl(rid);}}window.location.href = GetTwitterUrl(tagId, shareText);return;}}return (<div class={style.main}><ul class={style.share_1_link}><li class={style.share_1_link_intro} onClick={() => shareFriend("facebook")}><div class={style.share_1_link_img}><a href="javascript:;"  rel="noreferrer"><img src={"../images/share3.svg"} /></a></div><div class={style.share_1_link_text}>Facebook</div></li><li class={style.share_1_link_intro}  onClick={() => shareFriend("whatApp")}><div class={style.share_1_link_img}><a href="javascript:;" rel="noreferrer"><img src={"../images/share2.svg"} /></a></div><div class={style.bottom_share_1_link_text}>WhatApp</div></li><li class={style.share_1_link_intro}  onClick={() => shareFriend("telegram")}><div class={style.share_1_link_img}><a href="javascript:;" rel="noreferrer"><img src={"../images/share3.png"} /></a></div><div class={style.share_1_link_text}>Telegram</div></li><li class={style.share_1_link_intro}  onClick={() => shareFriend("twitter")}><div class={style.share_1_link_img}><a href="javascript:;"  rel="noreferrer"><img src={"../images/share4.svg"}/></a></div><div class={style.share_1_link_text}>Twitter</div></li><li class={style.share_1_link_intro}><div class={style.share_1_link_img}><a href={"mailto:test@test.com?body" + GetUrl(tagId)} rel="noreferrer"><img src={"../images/share5.svg"}/></a></div><div class={style.share_1_link_text}>Email</div></li></ul></div><div class={style.copy_url_area}><div class={style.copy_url_input}><span id="share_url">{GetUrl(tagId)}</span></div><CopyToClipboardtext={GetUrl(tagId)}onCopy={() => {Toast.success({message: "Copy Successfully",});}}><div class={style.action_btn} style={{ flexShrink: 0 }}>COPY URL</div></CopyToClipboard></div>)
}export default Index;

对上面代码的说明:

        当点击CPOY URL 按钮时,调用react-copy-to-clipboard组件复制分享链接到剪切板,点击平台分享图片时,调用shareFriend()方法,进行分享配置操作,获取分享的url,以及调用各个平台分享的api,然后配置head中分享的meta(如下代码,为什么需要配置meta,因为国外很多平台在分享图文链接时,是通过爬虫来抓取meta数据进行分享数据展示的),操作后,app会调起对应平台的app或者打开对应的web页面进行分享操作

html代码:

<head>
<meta id="og_url" property="og:url" content="" /><!-- facebook,whatApp分享--><meta id="og_description"  property="og:description" content="" /><meta id="og_image"  property="og:image" content="" /><meta id="og_title"  property="og:title" content="" /><!-- twitter分享--><meta  id="tw_card"  name="twitter:card" content=""><meta  id="tw_title" name="twitter:title" content=""><meta  id="tw_description" name="twitter:description" content=""><meta  id="tw_image" name="twitter:image" content=""><meta id="tw_url" property="twitter:url" content="" />
</head>

 对上面代码说明:

        meta中的数据,就是各个平台爬虫要抓取的分享数据,根据不同平台,meta的name不一样,具体情况可看各个平台官方文档

3.实现通过WhatsAPP以及SMS分享操作

  • 程序生成随机电话号码,默认选中第一个电话号码,点击WhatsAPP后,调取WhatApp相关方法接口,进行分享操作,然后电话号码变灰,当再次点击WhatsAPP时,触发下一个电话号码操作
  • 点击SMS按钮时,触发SMS接口请求,调用SMS相关url进行分享操作

代码如下: 

import React, {useState} from "react";
import axios from "axios";
import Scroll from "../../components/Scroll";
import {CountDown, Steps, Tabs, Toast, Popup, Cell, Dialog, Swiper, NoticeBar, Image} from "react-vant";
import {CopyToClipboard} from "react-copy-to-clipboard";const SinNumberGenerator = (x, offset) => {return (Math.sin(x + offset) + 1) / 2;
};//生成随机的分享电话号码:count 电话号码个数
const SharePhoneList = (count) => {let list = [];for (let i = 0; i < count; i++) {let phone = (SinNumberGenerator(((NowTimestamp / 100000) % 100000) / 50000 / Math.PI, i) * (99999 - 1000) +1000).toFixed(0);if (phone.length < 5) {phone = "0" + phone;}list.push({phone: phone, //电话号码state: Math.floor(Math.random()*2),  //发送状态});}return list;
};const Index = () => {//分享电话号码初始化const [sharePhoneList, setSharePhoneList] = useState([]);//当前选中电话号码索引const [checkedPhoneIndex, setCheckedPhoneIndex] = useState(0);//设置电话号码列表setSharePhoneList(SharePhoneList(20));setCheckedPhoneIndex(0);//分享url:拼接要分享的页面url,以及带上参数//注意:这里参数有的分享平台不支持?格式,可以使用简化格式,eg:http:www.test.com/target_page/100/paramconst GetUrl = (tagId) => {return `${window.location.origin}/target_page?param=${tagId}`;};const GetSeedWhatsAppUrl = (phone, tagId, text) => {return `https://api.whatsapp.com/send?phone=${phone}&text=` + encodeURIComponent(text) + encodeURIComponent("\n\n" + GetUrl(tagId));
};const GetSmsUrl = (phone, tagId, text) => {return "sms:/open?addresses=" + phone + "&body=" + encodeURIComponent(text + GetUrl(tagId));
};//发送whatsApp,smsconst SendMessage = (type= "whatsApp") => {if (checkedPhoneIndex >= 20) {return;}let phoneList = [];let checkedPhone = "";sharePhoneList.map((value, index) => {  //设置发送的号码状态if (index === checkedPhoneIndex) {  //如果当前电话号码索引和遍历的索引相同,则设置电话号码状态为已完成phoneList.push({phone:value.phone,state: 1,});checkedPhone = value.phone;} else {phoneList.push({phone:value.phone,state: value.state,});}});setCheckedPhoneIndex(checkedPhoneIndex + 1);//更新电话号码列表状态setSharePhoneList(phoneList); let link = GetSeedWhatsAppUrl(checkedPhone, tarId);//发送短信if (type === "sms") {link = GetSmsUrl(checkedPhone, tarId);}window.location.href = link;}return (<div class={style.main}><div class={style.bottom_share}><div class={style.bottom_share_title}>Share </div><div class={style.bottom_share_phones}>{sharePhoneList.map((value, index) => (<div class={`${style.bottom_share_phone_info} ${(value.state ? style.bottom_share_phone_ok : "")}`} id={value.state}>{value.phone}</div>))}</div><div class={style.phone_send}><div class={style.phone_send_info} onClick={() => SendMessage()}><div class={style.phone_send_text}><div class={style.phone_send_text1}>Send message</div><div class={style.phone_send_text2}><span>on </span><span class={style.phone_send_text2_font}>WhatsAPP</span></div></div><div class={style.phone_send_img}><img src={"../images/whatsApp.png"} style={{width: "80%"}}/></div></div><div class={style.phone_send_info} onClick={() => SendMessage("sms")}><div class={style.phone_send_img}><img src={"../images/sms.png"} style={{width: "80%"}}/></div><div class={style.phone_send_text} style={{marginLeft: "-1rem"}}><div class={style.phone_send_text1}>Send message</div><div class={style.phone_send_text2}><span class={style.phone_send_text2_font}>SMS</span></div></div></div></div></div></div>)
}export default Index;

css: 

.bottom_share {width: 100%;margin-top: 1.3rem;
}
.bottom_share_title {font-size: 0.9rem;
}.bottom_share_phones {background-color: rgba(0, 0, 0);color: #e6e3e3;display: -ms-flexbox;display: flex;width: 96%;font-size: 0.9rem;-ms-flex-wrap: wrap;flex-wrap: wrap;-ms-flex-align: center;align-items: center;-ms-flex-pack: distribute;-ms-flex-direction: row;margin-top: 0.7rem;padding-top: 0.5rem;justify-content: flex-start;flex-direction: row;
}.bottom_share_phone_info {margin: 0.2rem 1.1rem;
}.bottom_share_phone_ok {color: #555353;
}.phone_send {width: 92%;background-color: rgba(0,0,0);display: flex;margin-bottom: 1rem;padding-left: 0.5rem;padding-right: 0.5rem;
}.phone_send_info {margin: 0.6rem 0.2rem 1rem 0.2rem;display: flex;background-color:  #e6e3e3;flex-direction: row;align-items: center;justify-content: space-around;padding-top: 0.35rem;padding-bottom: 0.35rem;
}.phone_send_text {display: flex;color: #191717;font-weight: 500;font-size: 0.9rem;flex-direction: column;justify-content: center;
}.phone_send_text2_font {font-weight: 900;
}.phone_send_img {width: 30%;
}

 好了,网页/app复制分享链接到剪切板,分享到国外各大社交平台,通过WhatsApp方式分享以及SMS短信方式分享链接内容操作基本完成

4.拓展知识

(1).Facebook

        Facebook的分享原理: 告诉Facebook你想要分享的url,Facebook爬虫机器人会主动向这个url发起爬虫操作,对这个url进行html解析,分别拿到相对于的html元素图谱,然后获取图谱中的内容并跳转到Facebook的分享页面并把获取到的内容渲染出来,后面只要点击提交分享的按钮就可以实现分享网页的功能了;对于国外第三方的分享元素图谱,一般是写在html的head部分,官方文档:https://developers.facebook.com/docs/sharing/webmasters/images/

Facebook所对应的如下面所示:

<html>
<head>
<meta property="og:type" content="website" />
<meta property="og:url" content="要分享的链接" />
<meta property="og:title" content="标题" />
<meta property="og:description" content="简介" />
<meta property="og:image" content="图片" />
</head>
</html>

分享网页固定内容到Facebook

  • 使用浏览器自带分享功能 (只能分享到Facebook动态)
  • 使用js进行Facebook分享 (可分享到Facebook动态和好友)
const url = "http://www.test.cn"
const text = "share text"
widnow.open("http:/www.facebook.com/share.php?u="+ encodeURIComponent(u) + "&t="+ encodeURIComponent(t), "sharer","toolbar=0,status=0,width=626,height=436")
  • 分享到Facebook好友(messenger) PC端:需要登录Facebook获取appid
const url = "http://www.test.cn"
widnow.open("https:/www.facebook.com/dialog/send?app_id=1 xxxx11&link="+url+"&redirect_uri="+url+"","_blank")
  • 移动端
const url = "http://www.test.cn"
widnow.open("fb-messenger://share/?link="+url)

注意:

        如果meta已经写好了Facebook的分享内容,那么使用js改变mate分享内容是无效的,因为Facebook抓取meta是在js加载之前获取的,尽管通过js更改mate信息也无法改变Facebook已抓取到的信息,所以如果已经在head头部写好了meta的facebook分享内容,就无法通过js动态分享自定义文案

分享网页自定义内容到Facebook

        前端编辑参数,调用第三方的分享地址,第三方回调你传的参数,解析里面meta信息,然后返回html页面,再执行js动态分享内容

  • 分析到Facebook动态(PC端和移动端都适用)
let mateArr = ['og:url','http://www.test.cn','og:title','title','og:description','description','og:image','http:/xxx/static/image/test.jpg','og:type','website']
let mataParams = mateArr.toString()
window.open('http://www.facebook.com/sharer.php?u='+ encodeURIComponent(`http://xxx/share/detail?meta=${metaParams}`))
  •  分享到Facebook好友(messenger) PC端
let mateArr = ['og:url','http://www.test.cn','og:title','title','og:description','description','og:image','http://xxx/static/image/test.jpg','og:type','website']
let mataParams = mateArr.toString()
window.open('https:/www.facebook.com/dialog/send?app_id=1xxx12&link='+ encodeURIComponent(`http://xxx/share/detail?meta=${metaParams}`)+'redirect_uri='+encodeURIComponent(`http://xxx/share/detail?meta=${metaParams}`)+'','_blank')
  • 移动端
let mateArr = ['og:url','http://www.test.cn','og:title','title','og:description','description','og:image','http://zzz/static/image/test.jpg','og:type','website']
let mataParams = mateArr.toString()
widnow.open("fb-messenger://share/?link="+encodeURIComponent(`http://xxx/share/detail?meta=${metaParams}`)+"")

在分享到Facebook上时,需要注意一下几点

  • 1.og:url 中的 url地址禁止携带参数,即 https://test.com/index.htm?key=search错误,若确实需要,请将参数放到目录层级中,如https://testcom/search/index.htm
  • 2.og:image 中的url地址只要能满足让爬虫爬取即可,是否携带参数都可以
  • 3.分享到Facebook上的图片的最佳比例是1.91:1(矩形图)或1:1(正方形图),最小尺寸是200200,低于此尺寸图片将不显示,推荐尺寸是1200630或600*315
  • 4.分享图片无法自己定义显示尺寸,使用og:image:width与og:image:height也不行
  • 5.og:title 标签不存在时,则默认读取title标签里的内容作为分享的title
  • 6.因为分享的内容采用的是爬虫的形式获取,所以在html页面一开始就要存在og:标签,供爬虫,而不可以动态的通过js脚本追加
  • 7.对于动态生成html的情况,当采用的是前后端一体的方式,如.jsp、.asp、haml等形式时,在后端动态生成参数,然后传递给前端页面即可
  • 8.对于前后端分离的情况,需要后端配合动态生成html页面
  • 9.对于分享的链接能否正常显示,可以通过Facebook分享调试器进行调试,并查看结果

(2).WhatsApp

原理与Facebook一样,通过爬虫获取html头部head部分的mate:og信息,有一点需要注意:WhatsApp分享到好友PC端和移动端都可以使用同一套代码,

分享到网页版平台:https://web.whatsapp.com/send?text={内容}&url={链接}

通用链接:https://wa.me/?text={内容},会重定向到API网关然后通过url schema的方式唤起App

<html>
<head>
<meta property="og:type" content="website" />
<meta property="og:url" content="要分享的链接" />
<meta property="og:title" content="标题" />
<meta property="og:description" content="简介" />
<meta property="og:image" content="图片" />
</head>
</html>
const url = "http://www.test.cn"
const text = "share"
window.open("https://api.whatsapp.com/send?text="+encodeURIComponent(url)+encodeURIComponent(text)+"&via=lopscoop")

(3).twitter 

推特是比较简单的,可以在网页中通过链接,推特推荐在网页版打开,所以在一些浏览器可能会隐藏到App的入口(比如Chrome)。它的链接是一个universal link,格式如下: https://twitter.com/intent/tweet?text={内容}&url={链接},注意内容链接需要用encodeURIComponent加密一下,官方文档:https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/summary

代码如下:

  <meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="Parade of Fans for Houston’s Funeral"><meta name="twitter:description" content="分享的description"><meta name="twitter:image" content="分享图片的url">
//调用下面的js打开分享弹窗 
window.open(`https://twitter.com/share?url=${分享链接的url}`, `_blank`, `width=600, height=450, toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, top=100,left=350`)

注意: 

  • twitter:url 标签可有可无,因为默认采用的是 https://twitter.com/share?url=${分享链接的url} 中的url,url地址禁止携带参数,即 https://test.com/index.htm?key=search错误,若确实需要,请将参数放到目录层级中,如https://testcom/search/index.htm
  • twitter:title 标签必须有,否则无法显示分享的内容
  • twitter:image 中的url地址只要能满足让爬虫爬取即可,是否携带参数都可以
  • twitter:card 标签必须有,常用的summary_large_image表示以大图的排版展示,summary以小图的形式排版展示。其他的分享如视频等,请参考官方文档
  • 因为分享的内容采用的是爬虫的形式获取,所以在html页面一开始就要存在twitter:标签,供爬虫,而不可以动态的通过js脚本追加
  • 对于动态生成html的情况,当采用的是前后端一体的方式,如.jsp、.asp、haml等形式时,在后端动态生成参数,然后传递给前端页面即可
  • 对于前后端分离的情况,需要后端配合动态生成html页面
  • 对于分享的链接能否正常显示,可以通过Twitter分享调试器进行调试,并查看结果

(4).Telegram

仅支持分享到App端和桌面端:https://t.me/share?url={链接}&text={内容},也是url schema的方式

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

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

相关文章

DS线性表之链表

前言 我们上一期介绍了顺序表&#xff0c;它的底层就是数组&#xff0c;我们也分别对顺序表的动态版本和静态版本进行了实现&#xff01;并且分析了顺序表的优缺点&#xff0c;优点是&#xff1a;尾插、尾删效率很高&#xff0c;其时间复杂度是O(1)&#xff1b;缺点是&#xff…

代码随想录算法训练营第五十五天 | 动态规划 part 12 | 300.最长递增子序列、674. 最长连续递增序列、718. 最长重复子数组

目录 300.最长递增子序列思路代码 674. 最长连续递增序列思路代码 718. 最长重复子数组思路代码 300.最长递增子序列 Leetcode 思路 dp[i]表示i之前包括i的以nums[i]结尾的最长递增子序列的长度递推公式&#xff1a;if (nums[i] > nums[j]) dp[i] max(dp[i], dp[j] 1)初…

格点数据可视化(美国站点的日降雨数据)

获取美国站点的日降雨量的格点数据&#xff0c;并且可视化 导入模块 from datetime import datetime, timedelta from urllib.request import urlopenimport cartopy.crs as ccrs import cartopy.feature as cfeature import matplotlib.colors as mcolors import matplotli…

解决u盘在我的电脑中重复显示两个

删除注册表&#xff1a; [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\DelegateFolders\{F5FB2C77-0E2F-4A16-A381-3E560C68BC83}]

postgresql-备份与恢复

postgresql-备份与恢复 基本概念备份类型物理备份与逻辑备份在线备份与离线备份全量备份与增量备份 备份恢复工具备份与恢复逻辑备份与还原备份单个数据库psqlpg_dumppg_store 备份整个集群 基本概念 服务器系统错误、硬件故障或者人为失误都可能导致数据的丢失或损坏。因此&am…

Redis学习笔记(下):持久化RDB、AOF+主从复制(薪火相传,反客为主,一主多从,哨兵模式)+Redis集群

十一、持久化RDB和AOF 持久化&#xff1a;将数据存入硬盘 11.1 RDB&#xff08;Redis Database&#xff09; RDB&#xff1a;在指定的时间间隔内将内存中的数据集快照写入磁盘&#xff0c;也就是行话讲的Snapshot快照&#xff0c;它恢复时是将快照文件直接读到内存里。 备份…

vtk 动画入门 1 代码

实现效果如图&#xff1a; #include <vtkAutoInit.h> //VTK_MODULE_INIT(vtkRenderingOpenGL2); //VTK_MODULE_INIT(vtkInteractionStyle); VTK_MODULE_INIT(vtkRenderingOpenGL2); VTK_MODULE_INIT(vtkInteractionStyle); //VTK_MODULE_INIT(vtkRenderingFreeType); #in…

新手学习笔记-----编译和链接

目录 1. 翻译环境和运⾏环境 2. 翻译环境&#xff1a;预编译编译汇编链接 2.1 预处理 2.2 编译 2.2.1 词法分析 2.2.2 语法分析 2.2.3 语义分析 2.3 汇编 2.4 链接 3. 运⾏环境 1. 翻译环境和运⾏环境 在ANSI C的任何⼀种实现中&#xff0c;存在两个不同的环境。 第…

JSON的MIME媒体类型是application/json

JSON&#xff08;全称 JavaScript Object Notation&#xff09;即JavaScript对象表示法&#xff0c;通知使用application/json媒体类型。 目录 1、JSON介绍 2、JSON语法 3、实践总结 运行环境&#xff1a; Windows-7-Ultimate-x64、Windows-10-BusinessEditions-21h2-x64 1…

Can‘t pickle <class ‘__main__.Test‘>: it‘s not the same object as __main__.Test

目录 原因1 类名重复了 案例1 变量名和类名重复 原因1 类名重复了 检查项目代码&#xff0c;是不是其他地方有同名类。 案例1 变量名和类名重复 转自&#xff1a;python3报错Cant pickle <class __main__.Test>: its not the same object as __main__.Test解决 - 知乎…

SpringBoot Validation入参校验国际化

在 Spring Boot 中&#xff0c;可以使用 Validation 和国际化来实现对入参的校验。 常用的校验 NotNull验证字段值不能为 nullNotEmpty验证字段值不能为 null 或空字符串NotBlank验证字符串字段值不能为空、null&#xff0c;并且必须至少包含一个非空白字符Size验证字符串、…

lv8 嵌入式开发-网络编程开发 01什么是互联网

目录 1 计算机网络的定义与分类 1.1 按照网络的作用范围进行分类 1.2 按照网络的使用者进行分类 2 网络的网络 2.1 名词解释 2.2 边缘与核心 3 互联网基础结构发展的三个阶段 3.1 第一阶段&#xff1a;1969 – 1990 3.2 第二阶段&#xff1a;1985 – 1993 3.3 第三阶…

小谈设计模式(14)—建造者模式

小谈设计模式&#xff08;14&#xff09;—建造者模式 专栏介绍专栏地址专栏介绍 建造者模式角色分类产品&#xff08;Product&#xff09;抽象建造者&#xff08;Builder&#xff09;具体建造者&#xff08;Concrete Builder&#xff09;指挥者&#xff08;Director&#xff0…

Java之SpringCloud Alibaba【六】【Alibaba微服务分布式事务组件—Seata】

一、事务简介 事务(Transaction)是访问并可能更新数据库中各种数据项的一个程序执行单元(unit)。 在关系数据库中&#xff0c;一个事务由一组SQL语句组成。 事务应该具有4个属性: 原子性、一致性、隔离性、持久性。这四个属性通常称为ACID特性。 原子性(atomicity) ∶个事务…

Selenium上传文件有多少种方式?不信你有我全

Selenium 封装了现成的文件上传操作。但是随着现代前端框架的发展&#xff0c;文件上传的方式越来越多样。而有一些文件上传的控件&#xff0c;要做自动化控制会更复杂一些&#xff0c;这篇文章主要讨论在复杂情况下&#xff0c;如何通过自动化完成文件上传 1.input 元素上传文…

国庆作业6

TCP服务器 #include "head.h" #define PORT 2580 //端口号 #define IP "192.168.31.219" //本机IP int main(int argc, const char *argv[]) {sqlite3* dbNULL;if(sqlite3_open("./my.db",&db)!SQLITE_OK){fprintf(stde…

Python大数据之PySpark(四)SparkBaseCore

文章目录 SparkBase&Core环境搭建-Spark on YARN扩展阅读-Spark关键概念[了解]PySpark角色分析[了解]PySpark架构后记 SparkBase&Core 学习目标掌握SparkOnYarn搭建掌握RDD的基础创建及相关算子操作了解PySpark的架构及角色 环境搭建-Spark on YARN Yarn 资源调度框…

面试题:熟悉设计模式吗?谈谈简单工厂模式和策略模式的区别

刚刚接触设计模式的时候&#xff0c;我相信单例模式和工厂模式应该是用的最多的&#xff0c;毕竟很多的底层代码几乎都用了这些模式。自从接触了一次阿里的公众号发的一次文章关于 DDD的使用 以后&#xff0c;就逐渐接触了策略模式。现在在项目中运用最多的也是这几种设计模式了…

【深蓝学院】手写VIO第4章--基于滑动窗口算法的 VIO 系统:可观性和 一致性--笔记

0. 内容 T1. 参考SLAM14讲P247直接可写&#xff0c;注意 ξ 1 , ξ 2 \xi_1,\xi_2 ξ1​,ξ2​之间有约束&#xff08;关系&#xff09;。 套用舒尔补公式&#xff1a; marg掉 ξ 1 \xi_1 ξ1​之后&#xff0c;信息被传递到 L 1 和 L 2 L_1和L_2 L1​和L2​之间了。 T2.

趋势列表上又多了两个漏洞!

CVE-2023-24955 和 CVE-2023-29360 来自微软产品 5 月和 6 月的安全补丁报告。它们之所以特别危险&#xff0c;是因为出现了公开漏洞利用。 以下是详细信息。 第一个漏洞 CVE-2023-24955存在于 Microsoft SharePoint Server 中。它可导致远程代码执行。 它与覆盖随后由服务器执…