const axios = require('axios'); const querystring = require('querystring'); const config = require("../../../etc/config.json") const helper = require('../../helper'); const https = require('https'); const tools = require('../../../tools'); const fetch = require('node-fetch'); const CMD = {} const cookies = { passport_csrf_token: 'f6e9bb6f5be3ac1ca88eaef7ec45af18', sid_guard: '975a2c17dcea431af25f475a39199337%7C1751542938%7C5184000%7CMon%2C+01-Sep-2025+11%3A42%3A18+GMT', sessionid: '975a2c17dcea431af25f475a39199337', adUserId: '3657398892890426', distributorId: '1823565160001931' } const temp_cookie = `sid_guard=${cookies.sid_guard}; sessionid=${cookies.sessionid}` CMD.根据番茄免费ID查询付费书籍 = async function(bookId){ let client = tools.getOneNewClinet() try{ let response = await client.get(`${config.fanqie_config.find_child_book_host}${bookId}`) if(response.data["code"]==401){ throw response.data["msg"] } let book_info = response.data // console.log(book_info) let info = {} info.words = book_info.word_count info.book_name = book_info.book_name info.book_id = book_info.book_id info.publish_time = book_info.on_shelf_time info.author = book_info.author if(book_info.genre==8){ info.genre = 3; }else{ info.genre = 1; } return info; }catch(e){ console.error("qm_find_parent_book error:",e) return null } } CMD.根据番茄付费ID查询免费书籍 = async function(bookId){ let client = tools.getOneNewClinet() try{ let response = await client.get(`${config.fanqie_mf_config.find_parent_book_host}${bookId}`) if(response.data["code"]==401){ throw response.data["msg"] } let book_info = response.data let info = {} info.words = book_info.ad_word_number info.book_name = book_info.book_name info.book_id = book_info.book_id info.publish_time = book_info.on_shelf_time info.author = book_info.author if(book_info.genre==8){ info.genre = 3; }else{ info.genre = 1; } return info; }catch(e){ console.error("qm_find_parent_book error:",e) return null } } CMD.search_id = async function(bookId,distributorId){ const postData = { distributor_id: distributorId, ts: helper.getCurrentUnixTimestamp(), sign: helper.getSign(distributorId,config.fanqie_config.secretKey), book_id: bookId }; var url = `https://www.changdunovel.com/novelsale/openapi/content/book_meta/v1/?distributor_id=${postData.distributor_id}&ts=${postData.ts}&sign=${postData.sign}&book_id=${postData.book_id}` console.log("url",url) let response = await axios.get(url) return response.data } // 设置 Cookie CMD.search_name = function(keyword){ // 搜索关键词 const encodedKeyword = encodeURIComponent(keyword); // 对关键词进行 URL 编码 // 设置正确的 Cookie 字符串 const cookie = 'passport_csrf_token=82f80619e2d3c3eb0aa7962d7c94305e; sid_tt=c00d65a0717e75e79ad8aecaa82f4064; sessionid=c00d65a0717e75e79ad8aecaa82f4064'; // 设置请求的 URL const url = `https://www.changdunovel.com/novelsale/distributor/content/book/list/v1?permission_statuses=3,4&search_type=2&query=${encodedKeyword}&page_index=0&page_size=10`; // 设置请求头 const headers = { 'Accept': 'application/json, text/plain, */*', 'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7', 'Agw-Js-Conv': 'str', 'Appid': '546801', 'Apptype': '1', 'Cache-Control': 'no-cache', 'Cookie': cookie, 'Distributorid': '1814786227164185', 'Pragma': 'no-cache', 'Priority': 'u=1, i', 'Referer': `https://www.changdunovel.com/sale/novel/list?permission_statuses=3%2C4&search_type=2&query=${encodedKeyword}&page_index=1&page_size=10`, 'Sec-Ch-Ua': '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"macOS"', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36', 'X-Secsdk-Csrf-Token': 'DOWNGRADE' }; // 执行请求 axios.get(url, { headers }) .then(response => { console.log(response.data); // 输出结果 }) .catch(error => { console.error('Error:', error.message); // 输出错误信息 }); } CMD.search_new_id = async function(bookId,call_back){ const url = `${config.fanqie_config.search_id}${bookId}&t=1` try{ let client = tools.getOneNewClinet() let response = await client.get(url) if(response.data["code"]==401){ throw response.data["msg"] } let book_info = response.data let info = {} info.words = book_info.word_count info.book_name = book_info.book_name info.book_id = book_info.book_id info.publish_time = book_info.on_shelf_time info.author = book_info.author if(book_info.genre==8){ info.genre = 3; }else{ info.genre = 1; } return info; }catch(e){ console.error("search_new_id error:",e) return null } } CMD.search_mf_new_id = async function(bookId){ const url = `${config.fanqie_mf_config.search_id}${bookId}&t=1` try{ let client = tools.getOneNewClinet() let response = await client.get(url) if(response.data["code"]==401){ throw response.data["msg"] } let book_info = response.data let info = {} // console.log("book_info:",book_info) info.words = book_info.word_count info.book_name = book_info.book_name info.book_id = book_info.book_id info.publish_time = book_info.on_shelf_time info.author = book_info.author if(book_info.genre==8){ info.genre = 3; }else{ info.genre = 1; } return info; }catch(e){ console.error("search_new_id error:",e) return null } } module.exports = CMD;