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

比较好的网站开发教学网站搜索引擎优化的目的是

比较好的网站开发教学网站,搜索引擎优化的目的是,河北公司注册网上核名,建设工程教育网一建论坛这篇是在上一篇的基础上写的,这篇负责抖音作者详情页的视频转声音提取,这篇需要用到后端。 本地启动后端后,在控制台输入对应代码,即可实现hover在封面上,按d一键下载音频 控制台代码 // 获取作者的视频列表var liEle…

这篇是在上一篇的基础上写的,这篇负责抖音作者详情页的视频转声音提取,这篇需要用到后端。
本地启动后端后,在控制台输入对应代码,即可实现hover在封面上,按d一键下载音频

  • 控制台代码
// 获取作者的视频列表var liElements = document.querySelectorAll('ul[data-e2e="scroll-list"] li');// 添加鼠标悬停事件监听器liElements.forEach(function(li) {li.addEventListener('mouseenter', function() {// 添加键盘按下事件监听器document.addEventListener('keydown', keydownHandler);});li.addEventListener('mouseleave', function() {// 移除键盘按下事件监听器document.removeEventListener('keydown', keydownHandler);});});// 处理键盘按下事件function keydownHandler(event) {// 判断按下的键是否为 'D' 键,keyCode为 '68'if (event.keyCode === 68) {// 获取下载链接var sourceTag = document.querySelector('.basePlayerContainer xg-video-container > video > source:nth-child(1)');const alt = document.querySelector('.basePlayerContainer').previousElementSibling.querySelector('img').getAttribute('alt');// 找到第一个冒号并截取之后的部分let contentAfterColon = alt.includes(':') ? alt.split(':').slice(1).join(':'):alt;// 去除所有的.和空格let resultString = contentAfterColon.replace(/[.\s]/g, '');// 如果最终结果为空,替换为'空'const name = resultString === '' ? '空' : resultString;// 提取src属性值var url = sourceTag.getAttribute('src');// 执行下载操作,这里使用一个假设的下载函数downloadFile(url, name);}}function downloadFile(url, name) {// 发送POST请求到后台接口fetch('http://localhost:3000/convert', {method: 'POST',headers: {'Content-Type': 'application/json',},body: JSON.stringify({ videoUrl: url }),}).then((response) => response.blob()).then((blob) => {// 创建一个临时的<a>元素用于下载const a = document.createElement('a');const url = window.URL.createObjectURL(blob);a.href = url;a.download = name + '.mp3';// 触发点击事件以启动下载a.click();// 释放URL对象window.URL.revokeObjectURL(url);}).catch((error) => {console.error('Error:', error);alert('下载失败,原因:' + error)});
}
  • 后端 node 代码
const express = require('express');
const axios = require('axios');
const ffmpeg = require('fluent-ffmpeg');
const fs = require('fs');
const path = require('path');
const cors = require('cors');
const app = express();app.use(express.json());
// 允许所有域的请求
app.use(cors());app.post('/convert', async (req, res) => {try {const { videoUrl } = req.body;if (!videoUrl) {return res.status(400).json({ error: 'Missing videoUrl parameter' });}const videoFileName = 'inputVideo.mp4';const audioFileName = 'outputAudio.mp3';// Download the video fileconst response = await axios.get(videoUrl, { responseType: 'arraybuffer' });fs.writeFileSync(videoFileName, Buffer.from(response.data));// Convert video to audio using ffmpegawait new Promise((resolve, reject) => {ffmpeg().input(videoFileName).audioCodec('libmp3lame').toFormat('mp3').on('end', () => resolve()).on('error', (err) => reject(err)).save(audioFileName);});// Send the converted audio file to the clientres.download(audioFileName, (err) => {if (err) {console.error(err);res.status(500).json({ error: 'Internal server error' });}// Clean up temporary filesfs.unlinkSync(videoFileName);fs.unlinkSync(audioFileName);});} catch (err) {console.error(err);res.status(500).json({ error: 'Internal server error' });}
});const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {console.log(`Server is running on port ${PORT}`);
});

如果不想用控制台,也可以用暴力猴,暴力猴脚本如下:

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      2024-01-12
// @description  try to take over the world!
// @author       You
// @match        https://www.douyin.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=douyin.com
// @grant        none
// ==/UserScript==(function() {'use strict';// Your code here...// 目标节点var targetNode = document.querySelector('ul[data-e2e="scroll-list"]');// 初始时的li数量var initialCount = targetNode.children.length;// 配置观察器的设置var config = { childList: true };// 观察器回调var callback = function(mutationsList, observer) {// 当前的li数量var currentCount = targetNode.children.length;// 检查li数量是否增加if (currentCount > initialCount) {// 执行你的函数addWatch();console.log('添加监听器')// 更新初始时的li数量initialCount = currentCount;}};// 创建一个观察器实例并传入回调函数var observer = new MutationObserver(callback);// 使用配置和目标节点开始观察observer.observe(targetNode, config);// 给所有 li 添加监听器function addWatch() {// 获取作者的视频列表var liElements = document.querySelectorAll('ul[data-e2e="scroll-list"] li');// 添加鼠标悬停事件监听器liElements.forEach(function(li) {li.addEventListener('mouseenter', function() {// 添加键盘按下事件监听器document.addEventListener('keydown', keydownHandler);});li.addEventListener('mouseleave', function() {// 移除键盘按下事件监听器document.removeEventListener('keydown', keydownHandler);});});}// 处理键盘按下事件function keydownHandler(event) {// 判断按下的键是否为 'D' 键,keyCode为 '68'if (event.keyCode === 68) {// 获取下载链接var sourceTag = document.querySelector('.basePlayerContainer xg-video-container > video > source:nth-child(1)');const alt = document.querySelector('.basePlayerContainer').previousElementSibling.querySelector('img').getAttribute('alt');// 找到第一个冒号并截取之后的部分let contentAfterColon = alt.includes(':') ?alt.split(':').slice(1).join(':'):alt;// 去除所有的.和空格let resultString = contentAfterColon.replace(/[.\s]/g, '');// 如果最终结果为空,替换为'空'const name = resultString === '' ? '空' : resultString;// 提取src属性值var url = sourceTag.getAttribute('src');// 执行下载操作,这里使用一个假设的下载函数downloadFile(url, name);}}function downloadFile(url, name) {// 发送POST请求到后台接口fetch('http://localhost:3000/convert', {method: 'POST',headers: {'Content-Type': 'application/json',},body: JSON.stringify({ videoUrl: url }),}).then((response) => response.blob()).then((blob) => {// 创建一个临时的<a>元素用于下载const a = document.createElement('a');const url = window.URL.createObjectURL(blob);a.href = url;a.download = name + '.mp3';// 触发点击事件以启动下载a.click();// 释放URL对象window.URL.revokeObjectURL(url);}).catch((error) => {console.error('Error:', error);alert('下载失败,原因:' + error)});}})();
http://www.dinnco.com/news/87255.html

相关文章:

  • 做网站分流百度商家平台客服电话
  • 网站的建设服务最佳搜索引擎磁力
  • 网站公司怎么做运营网站如何推广出去
  • 国内自适应网站济宁seo公司
  • 类qq留言网站建设成品短视频app下载有哪些软件
  • 眉山市住房和城乡建设局网站站长之家的seo综合查询工具
  • 常州网站外包营销网站建设哪家快
  • 安徽旅游集团网站建设微信社群营销推广方案
  • 自己的电脑做网站服务器 买的服务器 速度网络黄页推广软件哪个好
  • 腾宁网络做网站互联网企业营销策略
  • 网站建设总结心得北京网站建设运营
  • 大连网站建设优化自媒体引流推广
  • 网站开发知识视频教程云seo关键词排名优化软件
  • 数据交易网站开发创建属于自己的网站
  • 长沙抖音推广代运营公司太原百度关键词优化
  • jquerymobile日本镇江百度seo
  • 大坪网站公司河南网站优化
  • 网站运营服务中心建设方案公司网站制作教程
  • 手机网站制作推广2022新闻热点事件简短30条
  • 泗泾做网站seo点击工具
  • 网站建设怎么做云南网络营销公司
  • 有一套源码做网站还差什么windows优化大师官方下载
  • 企业网站的建立和推广seo学院
  • 济南家居行业网站开发搜索引擎优化策略应该包括
  • 长春网长春网站建设络推广猪肉价格最新消息
  • 外贸商城网站天津seo优化公司
  • 重庆seo网站排名优化软文营销的五大注意事项
  • 家居饰品网站建设论文世界最新新闻
  • wordpress读取其他数据库企业seo推广外包
  • 阿里云静态网站托管网络推广渠道都有哪些