fq_search_book.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. const axios = require('axios');
  2. const querystring = require('querystring');
  3. const config = require("../../../etc/config.json")
  4. const helper = require('../../helper');
  5. const https = require('https');
  6. const tools = require('../../../tools');
  7. const fetch = require('node-fetch');
  8. const CMD = {}
  9. const cookies = {
  10. passport_csrf_token: 'f6e9bb6f5be3ac1ca88eaef7ec45af18',
  11. sid_guard: '975a2c17dcea431af25f475a39199337%7C1751542938%7C5184000%7CMon%2C+01-Sep-2025+11%3A42%3A18+GMT',
  12. sessionid: '975a2c17dcea431af25f475a39199337',
  13. adUserId: '3657398892890426',
  14. distributorId: '1823565160001931'
  15. }
  16. const temp_cookie = `sid_guard=${cookies.sid_guard}; sessionid=${cookies.sessionid}`
  17. CMD.根据番茄免费ID查询付费书籍 = async function(bookId){
  18. let client = tools.getOneNewClinet()
  19. try{
  20. let response = await client.get(`${config.fanqie_config.find_child_book_host}${bookId}`)
  21. if(response.data["code"]==401){
  22. throw response.data["msg"]
  23. }
  24. let book_info = response.data
  25. // console.log(book_info)
  26. let info = {}
  27. info.words = book_info.word_count
  28. info.book_name = book_info.book_name
  29. info.book_id = book_info.book_id
  30. info.publish_time = book_info.on_shelf_time
  31. info.author = book_info.author
  32. if(book_info.genre==8){
  33. info.genre = 3;
  34. }else{
  35. info.genre = 1;
  36. }
  37. return info;
  38. }catch(e){
  39. console.error("qm_find_parent_book error:",e)
  40. return null
  41. }
  42. }
  43. CMD.根据番茄付费ID查询免费书籍 = async function(bookId){
  44. let client = tools.getOneNewClinet()
  45. try{
  46. let response = await client.get(`${config.fanqie_mf_config.find_parent_book_host}${bookId}`)
  47. if(response.data["code"]==401){
  48. throw response.data["msg"]
  49. }
  50. let book_info = response.data
  51. let info = {}
  52. info.words = book_info.ad_word_number
  53. info.book_name = book_info.book_name
  54. info.book_id = book_info.book_id
  55. info.publish_time = book_info.on_shelf_time
  56. info.author = book_info.author
  57. if(book_info.genre==8){
  58. info.genre = 3;
  59. }else{
  60. info.genre = 1;
  61. }
  62. return info;
  63. }catch(e){
  64. console.error("qm_find_parent_book error:",e)
  65. return null
  66. }
  67. }
  68. CMD.search_id = async function(bookId,distributorId){
  69. const postData = {
  70. distributor_id: distributorId,
  71. ts: helper.getCurrentUnixTimestamp(),
  72. sign: helper.getSign(distributorId,config.fanqie_config.secretKey),
  73. book_id: bookId
  74. };
  75. 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}`
  76. console.log("url",url)
  77. let response = await axios.get(url)
  78. return response.data
  79. }
  80. // 设置 Cookie
  81. CMD.search_name = function(keyword){
  82. // 搜索关键词
  83. const encodedKeyword = encodeURIComponent(keyword); // 对关键词进行 URL 编码
  84. // 设置正确的 Cookie 字符串
  85. const cookie = 'passport_csrf_token=82f80619e2d3c3eb0aa7962d7c94305e; sid_tt=c00d65a0717e75e79ad8aecaa82f4064; sessionid=c00d65a0717e75e79ad8aecaa82f4064';
  86. // 设置请求的 URL
  87. 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`;
  88. // 设置请求头
  89. const headers = {
  90. 'Accept': 'application/json, text/plain, */*',
  91. 'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
  92. 'Agw-Js-Conv': 'str',
  93. 'Appid': '546801',
  94. 'Apptype': '1',
  95. 'Cache-Control': 'no-cache',
  96. 'Cookie': cookie,
  97. 'Distributorid': '1814786227164185',
  98. 'Pragma': 'no-cache',
  99. 'Priority': 'u=1, i',
  100. 'Referer': `https://www.changdunovel.com/sale/novel/list?permission_statuses=3%2C4&search_type=2&query=${encodedKeyword}&page_index=1&page_size=10`,
  101. 'Sec-Ch-Ua': '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
  102. 'Sec-Ch-Ua-Mobile': '?0',
  103. 'Sec-Ch-Ua-Platform': '"macOS"',
  104. 'Sec-Fetch-Dest': 'empty',
  105. 'Sec-Fetch-Mode': 'cors',
  106. 'Sec-Fetch-Site': 'same-origin',
  107. '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',
  108. 'X-Secsdk-Csrf-Token': 'DOWNGRADE'
  109. };
  110. // 执行请求
  111. axios.get(url, { headers })
  112. .then(response => {
  113. console.log(response.data); // 输出结果
  114. })
  115. .catch(error => {
  116. console.error('Error:', error.message); // 输出错误信息
  117. });
  118. }
  119. CMD.search_new_id = async function(bookId,call_back){
  120. const url = `${config.fanqie_config.search_id}${bookId}&t=1`
  121. try{
  122. let client = tools.getOneNewClinet()
  123. let response = await client.get(url)
  124. if(response.data["code"]==401){
  125. throw response.data["msg"]
  126. }
  127. let book_info = response.data
  128. let info = {}
  129. info.words = book_info.word_count
  130. info.book_name = book_info.book_name
  131. info.book_id = book_info.book_id
  132. info.publish_time = book_info.on_shelf_time
  133. info.author = book_info.author
  134. if(book_info.genre==8){
  135. info.genre = 3;
  136. }else{
  137. info.genre = 1;
  138. }
  139. return info;
  140. }catch(e){
  141. console.error("search_new_id error:",e)
  142. return null
  143. }
  144. }
  145. CMD.search_mf_new_id = async function(bookId){
  146. const url = `${config.fanqie_mf_config.search_id}${bookId}&t=1`
  147. try{
  148. let client = tools.getOneNewClinet()
  149. let response = await client.get(url)
  150. if(response.data["code"]==401){
  151. throw response.data["msg"]
  152. }
  153. let book_info = response.data
  154. let info = {}
  155. // console.log("book_info:",book_info)
  156. info.words = book_info.word_count
  157. info.book_name = book_info.book_name
  158. info.book_id = book_info.book_id
  159. info.publish_time = book_info.on_shelf_time
  160. info.author = book_info.author
  161. if(book_info.genre==8){
  162. info.genre = 3;
  163. }else{
  164. info.genre = 1;
  165. }
  166. return info;
  167. }catch(e){
  168. console.error("search_new_id error:",e)
  169. return null
  170. }
  171. }
  172. module.exports = CMD;