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

JS爬虫实战演练

在这个小红书私信通里面进行一个js的爬虫

文字发送

async function sendChatMessage(content) {const url = 'https://pro.xiaohongshu.com/api/edith/ads/pro/chat/chatline/msg';const params = new URLSearchParams({porch_user_id: '677e116404ee000000000001'});const messageData = {sender_porch_id: "677e116404ee000000000001",receiver_id: "612368ee000000000101cd0c",content: content,message_type: "TEXT",platform:3,uuid: uuid()};const headers = {'accept': 'application/json, text/plain, */*','accept-encoding': 'gzip, deflate, br, zstd','accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','authorization': 'AT-68c517457761645230526862lrx8ruxmrxwq0enw',  'content-type': 'application/json','origin': 'https://pro.xiaohongshu.com','referer': 'https://pro.xiaohongshu.com/im/multiCustomerService','sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"','sec-ch-ua-mobile': '?0','sec-ch-ua-platform': '"Windows"','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0','x-subsystem': 'ares'};try {console.log('发送数据:', messageData);const response = await fetch(`${url}?${params}`, {method: 'POST',headers: headers,credentials: 'include',body: JSON.stringify(messageData)});if (!response.ok) {const errorText = await response.text();console.error('错误详情:', errorText);throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);}const result = await response.json();console.log('发送成功:', result);return result;} catch (error) {console.error('发送失败:', error);throw error;}
}// 测试发送
async function testSend() {try {console.log('当前 cookie:', document.cookie);const result = await sendChatMessage("test message");console.log('发送结果:', result);} catch (error) {console.error('发送出错:', error);}
}
// 执行测试
testSend();

图片发送

//第一步进行token获取
async function getUploadTokenData() {// 构建URL和参数const baseUrl = 'https://pro.xiaohongshu.com/api/edith/ads/pro/chat/uploader/v3/token';const params = new URLSearchParams({biz_name: 'cs',scene: 'feeva_img',file_count: '1',version: '1',source: 'web'});try {const response = await fetch(`${baseUrl}?${params}`, {method: 'GET',headers: {'accept': 'application/json, text/plain, */*','authorization': 'AT-68c517457761645230526862lrx8ruxmrxwq0enw','x-b3-traceid': 'dba620e6f7ba1f67','x-subsystem': 'ares','referer': 'https://pro.xiaohongshu.com/im/multiCustomerService','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0'},credentials: 'include'  // 包含cookies});if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}const data = await response.json();// 检查响应是否成功并返回data部分if (data.success && data.code === 0) {return {success: true,data: data.data};} else {return {success: false,error: data.msg || '获取数据失败'};}} catch (error) {console.error('Error fetching upload token:', error);return {success: false,error: error.message};}
}// 使用示例
async function example() {try {const result = await getUploadTokenData();if (result.success) {console.log('Upload permits:', result.data.upload_temp_permits);console.log('Result:', result.data.result);// 获取具体的上传许可信息const permit = result.data.upload_temp_permits[0];console.log('File ID:', permit.file_ids[0]);console.log('Upload Token:', permit.token);console.log('Upload Address:', permit.upload_addr);console.log('Expire Time:', new Date(permit.expire_time));} else {console.error('Failed to get data:', result.error);}} catch (error) {console.error('Error:', error);}
}// 执行示例
example();//第二步put上传图片
async function uploadImageUrl(imageUrl) {// 1. 首先获取图片数据const imageResponse = await fetch(imageUrl);const imageBlob = await imageResponse.blob();// 2. 准备上传请求const uploadUrl = 'https://ros-upload.xiaohongshu.com/rimmatrix/V6nuam8zyZhLcjZdJfl1HEkhCXSx3GHlj2os4CEpSlVYbzo';try {const response = await fetch(uploadUrl, {method: 'PUT',headers: {'accept': '*/*','accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','authorization': 'q-sign-algorithm=sha1&q-ak=null&q-sign-time=1736479724;1736566124&q-key-time=1736479724;1736566124&q-header-list=content-length;host&q-url-param-list=&q-signature=18d7f7bce19414d500bf7bf33b2b027bc8fecc88','content-type': 'image/jpeg','origin': 'https://pro.xiaohongshu.com','referer': 'https://pro.xiaohongshu.com/','x-cos-security-token': 'iFbRMAXXIamH6mFfYAecIk6sRug:eyJkZWFkbGluZSI6MTczNjU3MDQ0OSwiYWxsb3dQcmVmaXhlcyI6WyJWNm51YW04enlaaExjalpkSmZsMUhFa2hDWFN4M0dIbGoyb3M0Q0VwU2xWWWJ6byJdfQ','sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"','sec-ch-ua-mobile': '?0','sec-ch-ua-platform': '"Windows"','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-site'},body: imageBlob});if (response.ok) {const previewUrl = response.headers.get('x-ros-preview-url');return {success: true,previewUrl: previewUrl,etag: response.headers.get('etag')};} else {throw new Error(`Upload failed with status: ${response.status}`);}} catch (error) {console.error('Error uploading image:', error);return {success: false,error: error.message};}
}// 使用示例:
const imageUrl = 'https://filecenter.kyliao.com:89/KYL/1/wxid_2a1a5t10214712/2025-01-09/3a71fa92-dce7-475f-ae44-ed62c79f7b5d.png'; // 替换为您的图片URL
uploadImageUrl(imageUrl).then(result => {if (result.success) {console.log('Upload successful!');console.log('Preview URL:', result.previewUrl);console.log('ETag:', result.etag);} else {console.error('Upload failed:', result.error);}}).catch(error => {console.error('Error:', error);});(0,De.Ix)//最后一步 msg发送
async function testSend() {try {// 先构造图片数据对象const imageData = {link: {cloudType: 4,bizName: "cs",scene: "feeva_img",fileId: "rimmatrix/RWuNee2PEHOq7_jYoFamLUouQZeS2uDXIbpwnuZr1F2CudM",preViewUrl: "https://ros-preview.xhscdn.com/rimmatrix/V6nuam8zyZhLcjZdJfl1HEkhCXSx3GHlj2os4CEpSlVYbzo?sign=ae5c1f2b90482122bd9262a2cfa12da6&t=1736485284"},size: {width: 337,height: 170}};console.log('当前 cookie:', document.cookie);// 发送消息时,需要修改 message_type 为 "IMAGE"const messageData = {sender_porch_id: "677e116404ee000000000001",receiver_id: "612368ee000000000101cd0c",content: JSON.stringify(imageData),  // 将图片数据转换为字符串message_type: "IMAGE",  // 改为 IMAGE 类型platform: 3,uuid: uuid()};const result = await sendChatMessage(messageData);console.log('发送结果:', result);} catch (error) {console.error('发送出错:', error);}
}// 修改 sendChatMessage 函数,直接接收消息数据对象
async function sendChatMessage(messageData) {const url = 'https://pro.xiaohongshu.com/api/edith/ads/pro/chat/chatline/msg';const params = new URLSearchParams({porch_user_id: '677e116404ee000000000001'});const headers = {'accept': 'application/json, text/plain, */*','accept-encoding': 'gzip, deflate, br, zstd','accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','authorization': 'AT-68c517457761645230526862lrx8ruxmrxwq0enw','content-type': 'application/json','origin': 'https://pro.xiaohongshu.com','referer': 'https://pro.xiaohongshu.com/im/multiCustomerService','sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"','sec-ch-ua-mobile': '?0','sec-ch-ua-platform': '"Windows"','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0','x-subsystem': 'ares'};try {console.log('发送数据:', messageData);const response = await fetch(`${url}?${params}`, {method: 'POST',headers: headers,credentials: 'include',body: JSON.stringify(messageData)});if (!response.ok) {const errorText = await response.text();console.error('错误详情:', errorText);throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);}const result = await response.json();console.log('发送成功:', result);return result;} catch (error) {console.error('发送失败:', error);throw error;}
}
// 执行测试
testSend();

回撤功能

//先发送消息 然后获取id
async function sendPostRequest() {const url = 'https://pro.xiaohongshu.com/api/edith/ads/pro/chat/chatline/msg?porch_user_id=677e116404ee000000000001';const payload = {sender_porch_id: "677e116404ee000000000001",receiver_id: "612368ee000000000101cd0c",content: "ccccc",message_type: "TEXT",platform: 3,uuid: "1736478957090-43350413"};const headers = {'accept': 'application/json, text/plain, */*','accept-encoding': 'gzip, deflate, br, zstd','accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','authorization': 'AT-68c517457761645230526862lrx8ruxmrxwq0enw','content-type': 'application/json','origin': 'https://pro.xiaohongshu.com','referer': 'https://pro.xiaohongshu.com/im/multiCustomerService','sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"','sec-ch-ua-mobile': '?0','sec-ch-ua-platform': '"Windows"','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0','x-subsystem': 'ares','cookie': 'abRequestId=f2154e9b-797b-5124-baaa-c2afb64b6f79; a1=194491d8b8fa14itukoamsqt4nf4p629kv1nvnb1250000382687; webId=0a7ab39304a5a8d090bd6ddcc8848598; web_session=030037a04c168270c118ba0407204a3a7c64a9; gid=yj44jyfj08Tfyj44jyfYDhIDYi0y4397Tl06yyJMA94IiI284UKJjh888qYJKYW8SjS84q4j; customerClientId=621527812963092; customer-sso-sid=68c5174577616452305268601fca10ccf489f9fe; x-user-id-pro.xiaohongshu.com=63a188ad0000000026013607; access-token-pro.xiaohongshu.com=customer.ares.AT-68c517457761645230526862lrx8ruxwq0enw; access-token-pro.beta.xiaohongshu.com=customer.ares.AT-68c517457761645230526862lrx8ruxwq0enw; xsecappid=pro-base; acw_tc=0a0d0e0317364784102826015e342af72d01e74806b984ca4f111406df3b0f; websectiga=10f9a40ba454a07755a08f27ef8194c53637eba4551cf9751c009d9afb564467; sec_poison_id=611c6572-b0c6-43fc-a7e7-dd15e153861d'};try {const response = await fetch(url, {method: 'POST',headers: headers,body: JSON.stringify(payload)});if (!response.ok) {const errorText = await response.text();console.error('请求失败:', errorText);throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);}const result = await response.json();console.log('请求成功:', result);// 提取 message_idconst messageId = result.data?.message_id;if (messageId) {console.log('Message ID:', messageId);} else {console.log('Message ID not found in response');}return result;} catch (error) {console.error('请求出错:', error);throw error;}
}// 调用函数发送请求
sendPostRequest();async function sendDeleteRequest() {const url = 'https://pro.xiaohongshu.com/api/edith/ads/pro/chat/chatline/msg';const params = new URLSearchParams({porch_user_id: '677e116404ee000000000001',id: '612368ee000000000101cd0c.63a188ad0000000026013607.1e78093375f6b8a',customer_user_id: '612368ee000000000101cd0c'});const headers = {'accept': 'application/json, text/plain, */*','accept-encoding': 'gzip, deflate, br, zstd','accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','authorization': 'AT-68c517457761645230526862lrx8ruxmrxwq0enw','origin': 'https://pro.xiaohongshu.com','referer': 'https://pro.xiaohongshu.com/im/multiCustomerService','sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"','sec-ch-ua-mobile': '?0','sec-ch-ua-platform': '"Windows"','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0','x-subsystem': 'ares','cookie': 'abRequestId=f2154e9b-797b-5124-baaa-c2afb64b6f79; a1=194491d8b8fa14itukoamsqt4nf4p629kv1nvnb1250000382687; webId=0a7ab39304a5a8d090bd6ddcc8848598; web_session=030037a04c168270c118ba0407204a3a7c64a9; gid=yj44jyfj08Tfyj44jyfYDhIDYi0y4397Tl06yyJMA94IiI284UKJjh888qYJKYW8SjS84q4j; customerClientId=621527812963092; customer-sso-sid=68c5174577616452305268601fca10ccf489f9fe; x-user-id-pro.xiaohongshu.com=63a188ad0000000026013607; access-token-pro.xiaohongshu.com=customer.ares.AT-68c517457761645230526862lrx8ruxmrxwq0enw; access-token-pro.beta.xiaohongshu.com=customer.ares.AT-68c517457761645230526862lrx8ruxmrxwq0enw; xsecappid=pro-base; acw_tc=0a0d0e0317364784102826015e342af72d01e74806b984ca4f111406df3b0f; websectiga=cf46039d1971c7b9a650d87269f31ac8fe3bf71d61ebf9d9a0a87efb414b816c; sec_poison_id=b36eccf0-9bce-4f66-8da8-20cd23f25541'};try {const response = await fetch(`${url}?${params}`, {method: 'DELETE',headers: headers});if (!response.ok) {const errorText = await response.text();console.error('请求失败:', errorText);throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);}const result = await response.json();console.log('请求成功:', result);return result;} catch (error) {console.error('请求出错:', error);throw error;}
}// 调用函数发送请求
sendDeleteRequest();

获取头像和昵称

async function getChatList() {const url = 'https://pro.xiaohongshu.com/api/edith/ads/pro/chat/chatline/chat';const params = new URLSearchParams({porch_user_id: '677e116404ee000000000001',limit: '80'});const headers = {'authority': 'pro.xiaohongshu.com','accept': 'application/json, text/plain, */*','accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','authorization': 'AT-68c517457761645230526862lrx8ruxmrxwq0enw','cookie': 'abRequestId=f2154e9b-797b-5124-baaa-c2afb64b6f79; a1=194491d8b8fa14itukoamsqt4nf4p629kv1nvnb1250000382687; webId=0a7ab39304a5a8d090bd6ddcc8848598; web_session=030037a04c168270c118ba0407204a3a7c64a9; gid=yj44jyfj08Tfyj44jyfYDhIDYi0y4397Tl06yyJMA94IiI284UKJjh888qYJKYW8SjS84q4j; customerClientId=621527812963092; customer-sso-sid=68c5174577616452305268601fca10ccf489f9fe; x-user-id-pro.xiaohongshu.com=63a188ad0000000026013607; access-token-pro.xiaohongshu.com=customer.ares.AT-68c517457761645230526862lrx8ruxmrxwq0enw; access-token-pro.beta.xiaohongshu.com=customer.ares.AT-68c517457761645230526862lrx8ruxmrxwq0enw; xsecappid=pro-base; acw_tc=0a4252f017364116529762089e968dff6b8b6e47ea444b0b76026fa2d1e664; websectiga=9730ffafd96f2d09dc024760e253af6ab1feb0002827740b95a255ddf6847fc8; sec_poison_id=f5e5bad7-0c91-4002-8189-51147435d119','referer': 'https://pro.xiaohongshu.com/im/liberal','sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"','sec-ch-ua-mobile': '?0','sec-ch-ua-platform': '"Windows"','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0','x-subsystem': 'ares'};try {const response = await fetch(`${url}?${params.toString()}`, {method: 'GET',headers: headers});if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}const data = await response.json();if (data.success && data.data && data.data.chat_list) {// 格式化聊天列表数据const formattedChats = data.data.chat_list.map(chat => {const timestamp = chat.sixin_chat.last_msg_ts;const date = new Date(timestamp);return {// 用户基本信息userInfo: {userId: chat.sixin_chat.user_id,nickname: chat.sixin_chat.nickname,avatarUrl: chat.sixin_chat.avatar,avatarLink: `头像链接: ${chat.sixin_chat.avatar}` // 新增头像链接显示},// 最后一条消息信息lastMessage: {content: chat.sixin_chat.last_msg_content,timestamp: timestamp,formattedTime: date.toLocaleString(),storeId: chat.sixin_chat.last_store_id},// 会话信息sessionInfo: {sessionId: chat.session.session_id,status: chat.session.state,replied: chat.session.is_replied,grantorUserId: chat.session.grantor_user_id},// 聊天状态chatStatus: {isActive: chat.long_chat_view.active,isFavorite: chat.long_chat_view.favorite,lastActiveTime: new Date(chat.long_chat_view.last_msg_ts).toLocaleString(),isBlacklisted: chat.in_blacklist}};});// 打印格式化后的数据console.log('\n=== 聊天列表摘要 ===');formattedChats.forEach((chat, index) => {console.log(`\n【聊天 ${index + 1}】`);console.log(`用户: ${chat.userInfo.nickname}`);console.log(`ID: ${chat.userInfo.userId}`);console.log(chat.userInfo.avatarLink);  // 显示头像链接console.log(`最新消息: ${chat.lastMessage.content}`);console.log(`发送时间: ${chat.lastMessage.formattedTime}`);console.log(`会话状态: ${chat.sessionInfo.status}`);console.log(`已回复: ${chat.sessionInfo.replied ? '是' : '否'}`);console.log(`活跃状态: ${chat.chatStatus.isActive ? '活跃' : '不活跃'}`);console.log('------------------------');});// 保存完整数据到文件if (typeof require !== 'undefined') {const fs = require('fs');fs.writeFileSync('formatted_chat_list.json', JSON.stringify(formattedChats, null, 2));console.log('\n详细数据已保存到 formatted_chat_list.json');}return formattedChats;}return null;} catch (error) {console.error('获取聊天列表失败:', error.message);return null;}
}// main函数保持不变
async function main() {try {console.log('正在获取聊天列表...');const chatList = await getChatList();if (chatList) {console.log(`\n成功获取 ${chatList.length} 个聊天会话`);// 统计信息const stats = {activeChats: chatList.filter(chat => chat.chatStatus.isActive).length,repliedChats: chatList.filter(chat => chat.sessionInfo.replied).length,favoriteChats: chatList.filter(chat => chat.chatStatus.isFavorite).length};console.log('\n=== 统计信息 ===');console.log(`活跃会话: ${stats.activeChats}`);console.log(`已回复会话: ${stats.repliedChats}`);console.log(`收藏会话: ${stats.favoriteChats}`);return chatList;}} catch (error) {console.error('执行出错:', error);}
}// 运行代码
main().catch(console.error);

完整Class封裝結合代碼

class XiaohongshuAPI {constructor() {this.baseUrl = 'https://pro.xiaohongshu.com/api';this.porchUserId = '677e116404ee000000000001';this.receiverId = '612368ee000000000101cd0c';this.headers = {'accept': 'application/json, text/plain, */*','accept-encoding': 'gzip, deflate, br, zstd','accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','authorization': 'AT-68c517457761645230526862lrx8ruxmrxwq0enw','content-type': 'application/json','origin': 'https://pro.xiaohongshu.com','referer': 'https://pro.xiaohongshu.com/im/multiCustomerService','sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"','sec-ch-ua-mobile': '?0','sec-ch-ua-platform': '"Windows"','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0','x-b3-traceid': 'c46a27c6cb6be409','x-subsystem': 'ares','cookie': document.cookie // 确保在浏览器环境中使用};}// 工具方法: 生成 UUID(需要实现或使用现有库)generateUUID() {// 简单的UUID生成方法(不保证唯一性,推荐使用库如 'uuid')return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {const r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);return v.toString(16);});}// 查看用户登录状态async fetchUserInfo() {const url = `${this.baseUrl}/eros/user/info`;try {const response = await fetch(url, {method: 'GET',headers: this.headers,credentials: 'include'});if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}const result = await response.json();// 检查是否有 data 字段if (result.data) {console.log('用户信息:', result.data);return result.data;} else {console.log('响应中未找到 data 字段');return null;}} catch (error) {console.error('获取用户信息时出错:', error);return null;}}// 发送消息async sendChatMessage(messageData) {const url = `${this.baseUrl}/edith/ads/pro/chat/chatline/msg`;const params = new URLSearchParams({porch_user_id: this.porchUserId});try {console.log('发送消息数据:', messageData);const response = await fetch(`${url}?${params}`, {method: 'POST',headers: this.headers,credentials: 'include',body: JSON.stringify(messageData)});if (!response.ok) {const errorText = await response.text();console.error('POST 请求失败:', errorText);throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);}const result = await response.json();console.log('发送成功:', result);const messageId = result.data?.message_id;if (messageId) {console.log('消息 ID:', messageId);return messageId;} else {console.log('响应中未找到消息 ID');return null;}} catch (error) {console.error('发送消息时出错:', error);return null;}}// 撤回消息async sendDeleteRequest(messageId) {const deleteUrl = `${this.baseUrl}/edith/ads/pro/chat/chatline/msg`;const params = new URLSearchParams({porch_user_id: this.porchUserId,id: messageId,customer_user_id: this.receiverId});try {const response = await fetch(`${deleteUrl}?${params}`, {method: 'DELETE',headers: this.headers});if (!response.ok) {const errorText = await response.text();console.error('DELETE 请求失败:', errorText);throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);}const deleteResult = await response.json();console.log('DELETE 请求成功:', deleteResult);return deleteResult;} catch (error) {console.error('撤回消息时出错:', error);return null;}}// 撤回模块: 发送消息并撤回async sendPostAndDeleteRequest(content = "ccccc") {try {// Step 1: 发送消息const messageId = await this.sendChatMessage({sender_porch_id: this.porchUserId,receiver_id: this.receiverId,content: content,message_type: "TEXT",platform: 3,uuid: this.generateUUID()});if (messageId) {// Step 2: 撤回消息await this.sendDeleteRequest(messageId);}} catch (error) {console.error('发送或撤回消息时出错:', error);}}// 获取聊天列表async getChatList() {const url = `${this.baseUrl}/edith/ads/pro/chat/chatline/chat`;const params = new URLSearchParams({porch_user_id: this.porchUserId,limit: '80'});try {const response = await fetch(`${url}?${params.toString()}`, {method: 'GET',headers: this.headers});if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}const data = await response.json();if (data.success && data.data && data.data.chat_list) {const formattedChats = data.data.chat_list.map(chat => {const timestamp = chat.sixin_chat.last_msg_ts;const date = new Date(timestamp);return {userInfo: {userId: chat.sixin_chat.user_id,nickname: chat.sixin_chat.nickname,avatarUrl: chat.sixin_chat.avatar,avatarLink: `头像链接: ${chat.sixin_chat.avatar}`},lastMessage: {content: chat.sixin_chat.last_msg_content,timestamp: timestamp,formattedTime: date.toLocaleString(),storeId: chat.sixin_chat.last_store_id},sessionInfo: {sessionId: chat.session.session_id,status: chat.session.state,replied: chat.session.is_replied,grantorUserId: chat.session.grantor_user_id},chatStatus: {isActive: chat.long_chat_view.active,isFavorite: chat.long_chat_view.favorite,lastActiveTime: new Date(chat.long_chat_view.last_msg_ts).toLocaleString(),isBlacklisted: chat.in_blacklist}};});console.log('\n=== 聊天列表摘要 ===');formattedChats.forEach((chat, index) => {console.log(`\n【聊天 ${index + 1}】`);console.log(`用户: ${chat.userInfo.nickname}`);console.log(`ID: ${chat.userInfo.userId}`);console.log(chat.userInfo.avatarLink);console.log(`最新消息: ${chat.lastMessage.content}`);console.log(`发送时间: ${chat.lastMessage.formattedTime}`);console.log(`会话状态: ${chat.sessionInfo.status}`);console.log(`已回复: ${chat.sessionInfo.replied ? '是' : '否'}`);console.log(`活跃状态: ${chat.chatStatus.isActive ? '活跃' : '不活跃'}`);console.log('------------------------');});// 保存完整数据到文件if (typeof require !== 'undefined') {const fs = require('fs');fs.writeFileSync('formatted_chat_list.json',JSON.stringify(formattedChats, null, 2));console.log('\n详细数据已保存到 formatted_chat_list.json');}return formattedChats;}console.log('响应数据不符合预期');return null;} catch (error) {console.error('获取聊天列表失败:', error.message);return null;}}// 获取上传令牌数据async getUploadTokenData() {const url = `${this.baseUrl}/edith/ads/pro/chat/uploader/v3/token`;const params = new URLSearchParams({biz_name: 'cs',scene: 'feeva_img',file_count: '1',version: '1',source: 'web'});try {const response = await fetch(`${url}?${params}`, {method: 'GET',headers: {'accept': 'application/json, text/plain, */*','authorization': 'AT-68c517457761645230526862lrx8ruxmrxwq0enw','x-b3-traceid': 'dba620e6f7ba1f67','x-subsystem': 'ares','referer': 'https://pro.xiaohongshu.com/im/multiCustomerService','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-origin','user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0'},credentials: 'include'});if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}const data = await response.json();if (data.success && data.code === 0) {return data.data.upload_temp_permits[0];} else {throw new Error(data.msg || '获取上传令牌数据失败');}} catch (error) {console.error('获取上传令牌时出错:', error);throw error;}}// 上传图片async uploadImage(imageUrl, permit) {try {const imageResponse = await fetch(imageUrl);const imageBlob = await imageResponse.blob();console.log('上传令牌:', permit.token);console.log('上传地址:', permit.upload_addr);console.log('文件ID:', permit.file_ids[0]);const uploadUrl = `https://ros-upload.xiaohongshu.com/${permit.file_ids[0]}`;const response = await fetch(uploadUrl, {method: 'PUT',headers: {'accept': '*/*','content-type': 'image/jpeg','authorization': permit.token,'origin': 'https://pro.xiaohongshu.com','referer': 'https://pro.xiaohongshu.com/','x-cos-security-token': permit.token,'sec-ch-ua': '"Microsoft Edge";v="131", "Chromium";v="131", "Not_A Brand";v="24"','sec-ch-ua-mobile': '?0','sec-ch-ua-platform': '"Windows"','sec-fetch-dest': 'empty','sec-fetch-mode': 'cors','sec-fetch-site': 'same-site'},body: imageBlob});if (response.ok) {const previewUrl = response.headers.get('x-ros-preview-url');console.log('图片上传成功,预览URL:', previewUrl);return {success: true,fileId: permit.file_ids[0],previewUrl: previewUrl};} else {throw new Error(`图片上传失败,状态码: ${response.status}`);}} catch (error) {console.error('上传图片时出错:', error);throw error;}}// 执行完整流程: 获取上传令牌 -> 上传图片 -> 发送图片消息async executeWorkflow(imageUrl) {try {// Step 1: 获取上传令牌const permit = await this.getUploadTokenData();console.log('获取到的上传许可:', permit);// Step 2: 上传图片const uploadResult = await this.uploadImage(imageUrl, permit);if (!uploadResult.success) {throw new Error('图片上传失败');}// Step 3: 发送图片消息const imageData = {link: {cloudType: 4,bizName: "cs",scene: "feeva_img",fileId: uploadResult.fileId,preViewUrl: uploadResult.previewUrl},size: {width: 337,height: 170}};const messageData = {sender_porch_id: this.porchUserId,receiver_id: this.receiverId,content: JSON.stringify(imageData),message_type: "IMAGE",platform: 3,uuid: this.generateUUID()};const sendResult = await this.sendChatMessage(messageData);console.log('图片消息发送结果:', sendResult);} catch (error) {console.error('执行完整流程时出错:', error);}}// 获取未回复的聊天数据async getChatData() {const url = `${this.baseUrl}/edith/ads/pro/chat/chatline/chat`;const params = new URLSearchParams({porch_user_id: this.porchUserId,limit: '80',is_active: 'true'});try {const response = await fetch(`${url}?${params.toString()}`, {method: 'GET',headers: this.headers});if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}const data = await response.json();const unrepliedChats = data.data.chat_list.filter(chat =>chat.session.is_replied === false);// 打印未回复的消息console.log('\n=== 未回复的消息 ===');unrepliedChats.forEach((chat, index) => {console.log(`\n--- 消息 ${index + 1} ---`);console.log('用户:', chat.sixin_chat.nickname);console.log('用户ID:', chat.sixin_chat.user_id);console.log('最后消息:', chat.sixin_chat.last_msg_content);console.log('发送时间:', new Date(chat.sixin_chat.last_msg_ts).toLocaleString());console.log('会话ID:', chat.session.session_id);console.log('会话状态:', chat.session.state);});// 如果在Node.js环境中,保存到文件if (typeof require !== 'undefined') {const fs = require('fs');fs.writeFileSync('full_response.json',JSON.stringify(data, null, 2));console.log('\n数据已保存到 full_response.json');}return data;} catch (error) {console.error('获取数据失败:', error.message);return null;}}
}// 使用示例
const api = new XiaohongshuAPI();// 查看用户登录状态
api.fetchUserInfo();// 发送并撤回消息
api.sendPostAndDeleteRequest(id,contactIMID);// 获取聊天列表
api.getChatList();// 执行上传并发送图片的完整流程
const imageUrl = 'https://filecenter.kyliao.com:89/KYL/1/wxid_2a1a5t10214712/2025-01-09/3a71fa92-dce7-475f-ae44-ed62c79f7b5d.png'; // 替换为您的图片URL
api.executeWorkflow(imageUrl);// 测试发送文本消息
// 测试发送文本消息
api.sendChatMessage({sender_porch_id: api.porchUserId,receiver_id: api.receiverId,content: "test message",message_type: "TEXT", // 确保包含 message_typeplatform: 3,uuid: api.generateUUID()
});// 获取未回复的聊天数据
api.getChatData();

相关文章:

JS爬虫实战演练

在这个小红书私信通里面进行一个js的爬虫 文字发送 async function sendChatMessage(content) {const url https://pro.xiaohongshu.com/api/edith/ads/pro/chat/chatline/msg;const params new URLSearchParams({porch_user_id: 677e116404ee000000000001});const messageD…...

JVM vs JDK vs JRE

JVM是Java虚拟机的缩写, 用于实现Java的一次编译,处处运行。 Java代码写成.class后,由本地的虚拟机运行。 JDK(Java Development Kit)是一个功能齐全的 Java 开发工具包,供开发者使用。 JDK包含了JRE。…...

OpenCV相机标定与3D重建(47)从两幅图像中的一组匹配点恢复相机的姿态(旋转和平移)函数recoverPose()的使用

操作系统:ubuntu22.04 OpenCV版本:OpenCV4.9 IDE:Visual Studio Code 编程语言:C11 算法描述 从两幅不同相机拍摄的图像中对应的点恢复相对相机旋转和平移,使用手性检查。返回通过该检查的内点数量。 cv::recoverPose 是 OpenCV…...

代码随想录算法训练营day27

代码随想录算法训练营 —day27 文章目录 代码随想录算法训练营前言一、贪心算法理论基础二、455.分发饼干三、376. 摆动序列53. 最大子数组和总结 前言 今天是算法营的第27天,希望自己能够坚持下来! 今日任务: ● 贪心算法理论基础 ● 455.…...

基于华为ENSP的OSPF状态机、工作过程、配置保姆级别详解(2)

本篇技术博文摘要 🌟 基于华为enspOSPF状态机、OSPF工作过程、.OSPF基本配置等保姆级别具体详解步骤;精典图示举例说明、注意点及常见报错问题所对应的解决方法 引言 📘 在这个快速发展的技术时代,与时俱进是每个IT人的必修课。我…...

【数据结构】链表

目录 ​编辑 1.2链表 1.2.1 链表的特性 1.2.2 单向链表 遍历无头单向链表 遍历有头单向链表 链表尾插法练习 1.2.3 单向链表的函数操作 单向链表的特点: 1.2链表 链表又称单链表、链式存储结构,用于存储逻辑关系为“一对一”的数据。 和顺序表…...

RabbitMQ解决消息积压的方法

目录 减少发送mq的消息体内容 增加消费者数量 批量消费消息 临时队列转移 监控和预警机制 分阶段实施 最后还有一个方法就是开启队列的懒加载 这篇文章总结一下自己知道的解决消息积压得方法。 减少发送mq的消息体内容 像我们没有必要知道一个的中间状态,只需…...

机器学习是?

机器学习(Machine Learning)是一门多领域交叉学科,涉及概率论、统计学、逼近论、凸分析、算法复杂度理论等多门学科; 是人工智能(AI)的一个分支,也是AI的核心领域,它专注于开发算法和模型&#…...

jupyter出现“.ipynb appears to have died. It will restart automatically.”解决方法

原因 解决方法:更新jupyter的版本 1.打开anaconda prompt 2、更新jupyter版本 在anaconda prompt输入以下指令 conda update jupyter如图:...

计算机毕业设计PyHive+Hadoop深圳共享单车预测系统 共享单车数据分析可视化大屏 共享单车爬虫 共享单车数据仓库 机器学习 深度学习

温馨提示:文末有 CSDN 平台官方提供的学长联系方式的名片! 温馨提示:文末有 CSDN 平台官方提供的学长联系方式的名片! 温馨提示:文末有 CSDN 平台官方提供的学长联系方式的名片! 作者简介:Java领…...

c++开源协程库libgo介绍及使用,srs协程,boost协程 Boost::fiber

https://www.cnblogs.com/qwsdcv/p/9115364.html Boost - 从Coroutine2 到Fiber - 开学五年级了 - 博客园 协程就是由程序员控制跑在线程里的“微线程”。它可以由程序员调度,切换协程时代价小(切换根据实现不同,消耗的CPU周期从几十到几百不等)&#x…...

微服务实现高并发 秒杀系统,前后端实现

一、前端实现 前端项目初始化 首先,我们需要创建一个新的 Vue 3 项目。你可以使用 Vue CLI 来快速搭建项目。 安装 Vue CLI(如果尚未安装) bash npm install -g vue/cli 创建 Vue 项目 bash vue create seckill-frontend cd seckill-f…...

Eureka缓存机制

一、Eureka的CAP特性 Eureka是一个AP系统,它优先保证可用性(A)和分区容错性(P),而不保证强一致性(C)。这种设计使得Eureka在分布式系统中能够应对各种故障和分区情况,保…...

PHP语言的学习路线

PHP语言的学习路线 PHP(Hypertext Preprocessor)是一种广泛使用的开源服务器端脚本语言,尤其适用于Web开发。由于其易学易用、功能强大,PHP成为了许多动态网站和Web应用程序开发的首选语言。随着Web3.0和云计算的兴起&#xff0c…...

python学opencv|读取图像(二十八)使用cv2.warpAffine()函数平移图像

【1】引言 前序已经对图像操作进行了广泛的学习,包括读取、放大缩小,改变BGR通道值等,相关链接包括且不限于: python学opencv|读取图像-CSDN博客 python学opencv|读取图像(三)放大和缩小图像_python(1)使…...

[Linux]Mysql9.0.1服务端脱机安装配置教程(redhat)

前言 本教程适用于在yum源不可用的LInux主机上安装Mysql的场景。 以redhat系主机做操作示例,debian系主机可参照步骤,将对应的rpm -ivh命令换成dpkg -i。 1. 官网下载安装包 https://dev.mysql.com/downloads/mysql/ 1.1 版本分类 MySQL Enterprise…...

个人 ALL IN ONE 方案搭建方案分享(从硬件到软件)及内网穿透方案

这里只做大概方案分享,每个虚拟机的部署细节滤过。 个人 ALL IN ONE 方案搭建方案分享 本指南将详细介绍如何基于现有硬件搭建一体化家庭/个人服务器解决方案,涵盖从软硬件配置、系统安装到功能实现以及性能优化的全过程。实现集 软路由、旁路由、NAS 网…...

TrustRAG:增强RAG系统鲁棒性与可信度的创新框架

在人工智能飞速发展的今天,大语言模型(LLMs)凭借其强大的语言处理能力在诸多领域大放异彩。检索增强生成(RAG)系统(面向企业RAG(Retrieval Augmented Generation)系统的多维检索框架…...

使用证件照制作软件的常见问题及解决方案

在数字化时代,证件照的制作变得越来越简单。借助各种证件照制作软件,我们可以轻松在家中制作出符合要求的证件照。然而,用户在使用这些软件时,可能会遇到一些常见问题。为了帮助您顺利制作出满意的证件照,我们整理了一…...

通过gradle发布aar或jar携带sources-jar到maven nexus

找了很久,没有找到满意的。终于找到一个好的办法。 gradle7.x适用。比以前的写法简洁。 发布传统的jar工程 比如okhttp,fastjson等项目,纯java工程。 直接创建新文件publish.gradle: apply plugin: maven-publishProperties properties …...

SAP推出云端ERP解决方案,加速零售行业数字化转型

2025年1月9日,SAP发布了一款专为零售行业设计的云端ERP行业解决方案——S/4HANA Cloud Public Edition,进一步推动企业向云端迁移。这款解决方案旨在集中运营数据,整合财务、采购和商品管理流程,以帮助零售企业优化运营效率。 核…...

RK3568 Android 13 内置搜狗输入法小计

问:为什么写? 答:网上搜出来的都试过了,不行!下面直接上代码和注意事项! 首先到这个目录(/RK3568/Rockchip_Android13_SDK_Release/device/rockchip/rk356x/tl3568_evm/preinstall&#xff09…...

微服务-Nacos(注册中心)

Nacos Nacos可以看作注册中心配置中心&#xff0c;比Eureka更加强大。 注册中心 在父工程中引入SpringCloudAlibaba的版本依赖 <dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-dependencies</artifactId&g…...

【数据结构:前缀树Trie】

目录 前言前缀树介绍和应用一、前缀树的定义前缀树的问题和思考前缀树的映射思想前缀树三大性质 二.前缀树节点结构三. 前缀树接口介绍和实现四个接口API1. insert(String word)2. search(String word)3. startsWith(String pre)4. delete(String word) API实现1. 查询操作sear…...

如何让QPS提升20倍

一、什么是QPS QPS&#xff0c;全称Queries Per Second&#xff0c;即每秒查询率&#xff0c;是用于衡量信息检索系统&#xff08;例如搜索引擎或数据库&#xff09;或请求-响应系统&#xff08;如Web服务器&#xff09;每秒能够处理的请求数或查询次数的一个性能指标。以下是…...

时间复杂度简介

定义 时间复杂度是用来衡量算法运行时间随着输入规模增长而增长的量级。简单来说&#xff0c;它描述了算法执行时间与数据规模之间的关系。我们通常用大O符号&#xff08; O O O&#xff09;来表示时间复杂度。例如&#xff0c;对于一个简单的加法运算&#xff0c;它的执行时间…...

记一次sealos部署k8s集群之delete了第一台master如何恢复

记一次sealos部署k8s集群之delete了第一台master如何恢复 一、背景描述 使用sealos部署了一套K8S集群 master信息:172.27.100.1、172.27.100.2、172.27.100.3 node信息:172.27.100.4、172.27.100.5 sealos安装在172.27.100.1节点,根目录下/root/.sealos/文件还在! [root…...

【json】

JSON JSON是一种轻量级的,按照指定的格式去组织和封装数据的数据交互格式。 本质上是一个带有特定格式的字符串(py打印json时认定为str类型) 在各个编程语言中流通的数据格式&#xff0c;负责不同编程语言中的数据传递和交互,类似于计算机普通话 python与json关系及相互转换…...

TypeScript语言的并发编程

TypeScript语言的并发编程 引言 随着现代应用程序的复杂性不断增加&#xff0c;性能和用户体验的重要性显得尤为突出。在这种背景下&#xff0c;并发编程应运而生&#xff0c;成为提升应用程序效率的重要手段。在JavaScript及其超集TypeScript中&#xff0c;尽管语言本身是单…...

左值引用(Lvalue Reference)和右值引用(Rvalue Reference)详解

左值引用&#xff08;Lvalue Reference&#xff09;和右值引用&#xff08;Rvalue Reference&#xff09;详解 文章目录 左值引用&#xff08;Lvalue Reference&#xff09;和右值引用&#xff08;Rvalue Reference&#xff09;详解1. 什么是左值和右值&#xff1f;左值&#x…...

音视频入门基础:RTP专题(1)——RTP官方文档下载

一、引言 实时传输协议&#xff08;Real-time Transport Protocol&#xff0c;简写RTP&#xff09;是一个网络传输协议&#xff0c;由IETF的多媒体传输工作小组1996年在《RFC 1889》中公布的。 RTP作为因特网标准在《RFC 3550》有详细说明。而《RFC 3551》详细描述了使用最小…...

【Flutter】使用ScrollController配合EasyRefresh实现列表预加载:在还未滑动到底部时加载下一页数据

需求/背景 在我们的业务场景中&#xff0c;列表的加载使用easy_refresh组件&#xff1a; https://pub.dev/packages/easy_refresh 大概效果是往上滑动到一定的offset会触发一个上滑加载&#xff0c;可以触发一些网络请求拉取列表后面的数据来展示。 这种模式一般在一页翻完…...

js实现md5加密

要在JavaScript中实现MD5加密并截取特定位置的字符&#xff0c;你可以使用像crypto-js这样的库。首先&#xff0c;你需要确保你的项目中包含了crypto-js库。如果你是在浏览器环境中&#xff0c;可以通过CDN引入&#xff1b;如果是在Node.js环境中&#xff0c;可以通过npm安装。…...

[java基础-集合篇]LinkedList源码粗析

LinkedList 的数据结构 实现List、Deque 接口&#xff0c;基于 双向链表实现的列表。与基于数组的 ArrayList 不同&#xff0c;基于链表的LinkedList 允许在列表的任何位置快速地插入和删除元素。 Java中LinkedList实现了Deque&#xff0c;它提供了 add, offer, remove, poll, …...

【Rust自学】11.1. 编写和运行测试

喜欢的话别忘了点赞、收藏加关注哦&#xff0c;对接下来的教程有兴趣的可以关注专栏。谢谢喵&#xff01;(&#xff65;ω&#xff65;) 11.1.1. 什么是测试 在Rust里一个测试就是一个函数&#xff0c;它被用于验证非测试代码的功能是否和预期一致。 在一个测试的函数体里通…...

移动端屏幕分辨率rem,less

谷歌模拟器&#xff1a;能直接看到移动端效果 屏幕分辨率 右键电脑桌面 &#xff0c;点击显示设置 PC端是逻辑分辨率&#xff0c;移动端代码也是参考逻辑分辨率 网页端宽度和逻辑分辨率尺寸相同 手机屏幕尺寸不同&#xff0c;网页宽度均为 100% 所以就需要添加视口标签&#x…...

rk3568 , buildroot , qt ,使用sqlite, 动态库, 静态库

问题说明&#xff1a; 客户反馈 &#xff0c;buildroot 系统 &#xff0c;使用qt 使用sqlite &#xff0c;有报错&#xff0c;无法使用sqlite. 测试情况说明&#xff1a; 我自己测试&#xff0c;发现&#xff0c; buildroot 自己默认就是 使能了 sqlite 的。 是否解决说明&…...

web-app uniapp监测屏幕大小的变化对数组一行展示数据作相应处理

web-app uniapp监测屏幕大小的变化对数组一行展示数据作相应处理 1.uni.getSystemInfoSync().screenWidth; 获取屏幕宽度 2.uni.onWindowResize&#xff08;&#xff09; 实时监测屏幕宽度变化 3.根据宽度的大小拿到每行要展示的数量itemsPerRow 4.为了确保样式能够根据 items…...

Airflow:TimeSensor感知时间条件

在数据管道工作流中&#xff0c;任务可能需要在特定的时间执行&#xff0c;或者在继续之前等待一定的时间。为了满足这些需求&#xff0c;Apache Airflow提供了TimeSensor&#xff0c;这是一种内置Sensor&#xff0c;可以监控当前时间&#xff0c;并在达到指定时间时触发后续任…...

使用Python和Neo4j驱动程序来实现小规模数据的CSV导入

要将CSV数据导入到Neo4j数据库中&#xff0c;你可以使用Neo4j提供的工具&#xff0c;比如neo4j-admin import命令&#xff08;适用于大规模数据导入&#xff09;&#xff0c;或者使用Python的Neo4j驱动程序通过Cypher查询逐行插入数据&#xff08;适用于小规模数据导入&#xf…...

网络安全测评技术与标准

网络安全测评概况 网络安全测评是网络信息系统和IT技术产品的安全质量保障。本节主要阐述网络安全测评的概念&#xff0c;给出网络安全测评的发展状况。 18.1.1 网络安全测评概念 网络安全测评是指参照一定的标准规范要求&#xff0c;通过一系列的技术和管理方法&#xff0c;获…...

某漫画网站JS逆向反混淆流程分析

文章目录 1. 写在前面1. 接口分析2. 反混淆分析 【&#x1f3e0;作者主页】&#xff1a;吴秋霖 【&#x1f4bc;作者介绍】&#xff1a;擅长爬虫与JS加密逆向分析&#xff01;Python领域优质创作者、CSDN博客专家、阿里云博客专家、华为云享专家。一路走来长期坚守并致力于Pyth…...

如何获取文件的MIME类型

文章目录 1. 概念介绍2. 方法与类型2.1 使用方法2.2 常见类型3. 示例代码4. 内容总结我们在上一章回中介绍了"如何加载本地图片"相关的内容,本章回中将介绍如何获取文件类型.闲话休提,让我们一起Talk Flutter吧。 1. 概念介绍 我们在本章回中提到的文件类型是指MI…...

Three.js 基础概念:构建3D世界的核心要素

文章目录 前言一、场景&#xff08;Scene&#xff09;二、相机&#xff08;Camera&#xff09;三、渲染器&#xff08;Renderer&#xff09;四、物体&#xff08;Object&#xff09;五、材质&#xff08;Material&#xff09;六、几何体&#xff08;Geometry&#xff09;七、光…...

Linux web服务器

Linux 作为 Web 服务器操作系统 安装 Web 服务器软件&#xff08;以 Apache 为例&#xff09; 步骤一&#xff1a;更新系统软件包列表 在 CentOS 系统中&#xff0c;使用命令 yum update -y 这个命令会连接到 CentOS 的软件包仓库&#xff0c;检查所有已安装软件包是否有更…...

Linux 下信号的保存和处理

信号的几个状态 信号抵达: 当接收到的信号被处理时, 此时就成为信号的抵达信号的未决: 从信号的产生到信号抵达这个时间段之间, 称为信号未决信号阻塞: 当进程设置了某个信号为阻塞后, 这个进程就不会在接收到这个信号信号忽略: 将信号设置为忽略后, 接收到这个信号, 对这个信…...

宝塔安装教程,bt怎么安装 linux

Centos安装脚本 yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh 37a09b35 Ubuntu/Deepin安装脚本 wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo b…...

java通过ocr实现识别pdf中的文字

需求&#xff1a;识别pdf文件中的中文 根据github项目mymonstercat 改造,先将pdf文件转为png文件存于临时文件夹&#xff0c;然后通过RapidOcr转为文字,最后删除临时文件夹 1、引入依赖 <dependency><groupId>org.apache.pdfbox</groupId><artifactId&g…...

基于SpringBoot的养老院管理系统

作者&#xff1a;计算机学姐 开发技术&#xff1a;SpringBoot、SSM、Vue、MySQL、JSP、ElementUI、Python、小程序等&#xff0c;“文末源码”。 专栏推荐&#xff1a;前后端分离项目源码、SpringBoot项目源码、Vue项目源码、SSM项目源码、微信小程序源码 精品专栏&#xff1a;…...

阿里云发现后门webshell,怎么处理,怎么解决?

当收到如下阿里云通知邮件时&#xff0c;大部分管理员都会心里一惊吧&#xff01;出现Webshell&#xff0c;大概是网站被入侵了。 尊敬的 xxxaliyun.com&#xff1a; 云盾云安全中心检测到您的服务器&#xff1a;47.108.x.xx&#xff08;xx机&#xff09;出现了紧急安全事件…...