当前位置: 首页 > news >正文

南京律师网站建设seo代码优化步骤

南京律师网站建设,seo代码优化步骤,如何查询网站是谁做的,做拼多多网站免费课程前两篇主要讲解了抖音和快手的图集短视频对去水印解析的云函数开发实践,今天说一些小红书图集解析的云函数实践。 图集短视频去水印云函数开发实践——抖音 图集短视频去水印云函数开发实践——快手 其实都是大差不差的,首先获取到小红书的分享链接&…

前两篇主要讲解了抖音和快手的图集短视频对去水印解析的云函数开发实践,今天说一些小红书图集解析的云函数实践。

图集短视频去水印云函数开发实践——抖音

图集短视频去水印云函数开发实践——快手

其实都是大差不差的,首先获取到小红书的分享链接,然后重定向到原地址,然后直接请求这个地址,获取到网页HTML,直接从中提取,这里比抖音快手还要简单一些。具体代码如下:

async getRedirectUrl(url) {try {const response = await this.curl(url, {method: "GET",headers: this.headers,followRedirect: false,});return this.safeGet(response, 'headers.location', url);} catch (error) {console.error("获取重定向URL时出错:", error);throw error;}}async getHtml(url) {try {const response = await this.curl(url, {headers: this.headers,dataType: "text",});return this.safeGet(response, 'data', null);} catch (error) {console.error("获取网页内容失败:", error);return null;}}parseHtml(html) {const jsonMatch = html.match(/<script>window\.__INITIAL_STATE__=(.*?)<\/script>/);if (!jsonMatch || jsonMatch.length < 2) {console.error("无法找到笔记信息");return null;}try {let jsonString = jsonMatch[1].replace(/undefined/g, "null");const data = JSON.parse(jsonString);const noteId = Object.keys(this.safeGet(data, 'note.noteDetailMap', {}))[0];if (!noteId) {console.error("无法找到笔记ID");return null;}const noteData = this.safeGet(data, `note.noteDetailMap.${noteId}.note`, null);if (!noteData) {console.error("无法获取笔记数据");return null;}const result = {title: this.safeGet(noteData, 'title', ''),desc: this.safeGet(noteData, 'desc', ''),type: this.safeGet(noteData, 'type', ''),user: {nickname: this.safeGet(noteData, 'user.nickname', ''),avatar: this.safeGet(noteData, 'user.avatar', ''),userId: this.safeGet(noteData, 'user.userId', ''),},time: this.safeGet(noteData, 'time', ''),likes: this.safeGet(noteData, 'interactInfo.likedCount', '0'),comments: this.safeGet(noteData, 'interactInfo.commentCount', '0'),collects: this.safeGet(noteData, 'interactInfo.collectedCount', '0'),view_count: this.safeGet(noteData, 'interactInfo.viewCount', '0'),share_count: this.safeGet(noteData, 'interactInfo.shareCount', '0'),platform: "xiaohongshu",};if (noteData.type === "video") {result.video = {url: this.safeGet(noteData, 'video.media.stream.h264.0.masterUrl', ''),cover: this.safeGet(noteData, 'video.cover.url', ''),};} else {result.images = this.safeGet(noteData, 'imageList', []).map((img) => ({url: this.safeGet(img, 'urlDefault', '') || this.safeGet(img, 'url', ''),width: this.safeGet(img, 'width', 0),height: this.safeGet(img, 'height', 0),}));}return result;} catch (error) {console.error("解析笔记信息失败:", error);return null;}}// 辅助方法:将字符串解析为数字parseNumber(value) {if (typeof value === "number") return value;if (!value) return 0;const num = parseInt(value.replace(/[^0-9]/g, ""));return isNaN(num) ? 0 : num;}safeGet(obj, path, defaultValue = '') {return path.split('.').reduce((acc, part) => {if (acc && typeof acc === 'object' && part in acc) {return acc[part];}return defaultValue;}, obj);}

没那么多废话了,看代码应该就可以明白了,不明白的留言问就好了。

http://www.dt0577.cn/news/14870.html

相关文章:

  • 美国做义工的网站交换友情链接的渠道有哪些
  • 网站建设 自适应商丘seo公司
  • 怎么搭建wap网站seo排名优化怎么样
  • 邢台网站制作哪里好企业网站制作价格
  • 嘉定西安网站建设代引流推广公司
  • 海口网站建设运营百度权重
  • 建设网站设计网络营销策划模板
  • 下载了源码怎么做网站北京网络营销外包公司哪家好
  • 买完域名后如何建设网站sem代运营推广公司
  • 软件下载网站模板那个推广平台好用
  • 重庆快速网站建设天津优化代理
  • 成都网站建设低价aso网站
  • 修改wordpress登录密码忘记百度网站怎样优化排名
  • 平台类网站建设价格表百度平台我的订单查询在哪里
  • thinkphp怎么做网站seo排名查询
  • 做网站编辑好还是推广好谷歌官网下载
  • 自己怎么做网站卖东西短视频代运营费用明细
  • 哪个网站做网站方便百度推广电话销售话术
  • 有哪些网站可以做设计比赛宁夏百度公司
  • 做网站的流程视频百度关键词排名靠前
  • 如何用个人电脑做网站百度关键词推广价格
  • 天津自助建站郑州seo实战培训
  • 电商网站建设实训心得百度竞价渠道户
  • 网站建设有哪几个方面seo优化内页排名
  • 手机app制作软件免费搜狗seo
  • 基础建站如何提升和优化搜狗收录查询
  • 百度网盘 做网站图床google搜索首页
  • 松江做微网站提高工作效率整改措施
  • 温州做网站找哪家好关联词有哪些类型
  • 用dw做的网站怎么上线站长工具精华