|
@@ -63,72 +63,20 @@ CMD.search_name = function(keyword){
|
|
|
}
|
|
|
|
|
|
CMD.search_new_id = async function(bookId,call_back){
|
|
|
- const https = require('https');
|
|
|
+ const params = new URLSearchParams({
|
|
|
+ permission_statuses: '3,4',
|
|
|
+ search_type: '5',
|
|
|
+ query: bookId,
|
|
|
+ page_index: '0',
|
|
|
+ page_size: '1',
|
|
|
+ msToken: 'QtOXD1IEPGNjuwS8Lzzew68qWnqxmVU10gPxOLcbijTXMmshIe_toySxUmiovwVBez7c8O3QcscyRES2_uC',
|
|
|
+ a_bogus: 'D7UVhFyEYZW5F3AG8OsveV2UN69lr08y7FTdRt697NxbThUPk8e1NPe5noLRXP3XauBNZ9OHAn4MudpcKcziZSpkwmZDSN0ftGCA9g8Lh17IaTkgVHWqCGSwok3n/cWEmA1txemvUULaZfOlk1QZMddeq/4oQODdbi9hfNfai1wg6sta7Qy='
|
|
|
+ });
|
|
|
|
|
|
- const options = {
|
|
|
- hostname: 'www.changdunovel.com',
|
|
|
- path: '/novelsale/distributor/content/book/list/v1',
|
|
|
- method: 'GET',
|
|
|
+ const config = {
|
|
|
+ method: 'get',
|
|
|
+ url: `https://www.changdunovel.com/novelsale/distributor/content/book/list/v1?${params.toString()}`,
|
|
|
headers: {
|
|
|
- 'accept': 'application/json, text/plain, */*',
|
|
|
- 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
|
|
- 'agw-js-conv': 'str',
|
|
|
- 'appid': '40017687',
|
|
|
- 'apptype': '15',
|
|
|
- 'distributorid': '1819222136130603',
|
|
|
- 'priority': 'u=1, i',
|
|
|
- 'sec-ch-ua': '"Microsoft Edge";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
|
|
|
- 'sec-ch-ua-mobile': '?1',
|
|
|
- 'sec-ch-ua-platform': '"Android"',
|
|
|
- 'sec-fetch-dest': 'empty',
|
|
|
- 'sec-fetch-mode': 'cors',
|
|
|
- 'sec-fetch-site': 'same-origin',
|
|
|
- 'x-secsdk-csrf-token': '00010000000165946eed4d812d087c4148a726264fe223e04f1c6e23eb1a0ebb30e517cbcf91183afa24b99abee3',
|
|
|
- 'cookie': 'store-region=cn-gd; store-region-src=uid; is_staff_user=false; passport_csrf_token=4d1582c647abf363099fe8a4f975751e; passport_csrf_token_default=4d1582c647abf363099fe8a4f975751e; s_v_web_id=verify_m8fcj8us_JZLlXrhR_OZsr_42Uz_BjhU_sRduBwB5eG8l; n_mh=-Akptc0OjS9zIJQaCBO_o6uzJlp3wAItgZeldsCLFeU; sid_guard=6cda0bf1f5b9891a648e6193dbd4b600%7C1745982840%7C5184000%7CSun%2C+29-Jun-2025+03%3A14%3A00+GMT; uid_tt=b3bebe7098b5f11e07d1d5dd8238d822; uid_tt_ss=b3bebe7098b5f11e07d1d5dd8238d822; sid_tt=6cda0bf1f5b9891a648e6193dbd4b600; sessionid=6cda0bf1f5b9891a648e6193dbd4b600; sessionid_ss=6cda0bf1f5b9891a648e6193dbd4b600'
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- // 构建查询参数
|
|
|
- const params = new URLSearchParams({
|
|
|
- permission_statuses: '3,4',
|
|
|
- search_type: '5',
|
|
|
- query: `${bookId}`,
|
|
|
- page_index: '0',
|
|
|
- page_size: '1',
|
|
|
- msToken: 'QtOXD1IEPGNjuwS8Lzzew68qWnqxmVU10gPxOLcbijTXMmshIe_toySxUmiovwVBez7c8O3QcscyRES2_uC',
|
|
|
- a_bogus: 'D7UVhFyEYZW5F3AG8OsveV2UN69lr08y7FTdRt697NxbThUPk8e1NPe5noLRXP3XauBNZ9OHAn4MudpcKcziZSpkwmZDSN0ftGCA9g8Lh17IaTkgVHWqCGSwok3n/cWEmA1txemvUULaZfOlk1QZMddeq/4oQODdbi9hfNfai1wg6sta7Qy='
|
|
|
- });
|
|
|
-
|
|
|
- options.path += `?${params.toString()}`;
|
|
|
-
|
|
|
- const req = https.request(options, (res) => {
|
|
|
- let data = '';
|
|
|
-
|
|
|
- res.on('data', (chunk) => {
|
|
|
- data += chunk;
|
|
|
- });
|
|
|
-
|
|
|
- res.on('end', () => {
|
|
|
- call_back(JSON.parse(data))
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- req.on('error', (error) => {
|
|
|
- call_back(null)
|
|
|
- console.error(error);
|
|
|
- });
|
|
|
-
|
|
|
- req.end();
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-CMD.search_mf_new_id = async function(bookId,call_back){
|
|
|
-
|
|
|
- const options = {
|
|
|
- hostname: 'www.changdunovel.com',
|
|
|
- path: '/novelsale/distributor/content/book/list/v1',
|
|
|
- method: 'GET',
|
|
|
- headers: {
|
|
|
'accept': 'application/json, text/plain, */*',
|
|
|
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
|
|
'agw-js-conv': 'str',
|
|
@@ -144,11 +92,69 @@ CMD.search_mf_new_id = async function(bookId,call_back){
|
|
|
'sec-fetch-site': 'same-origin',
|
|
|
'x-secsdk-csrf-token': '00010000000165946eed4d812d087c4148a726264fe223e04f1c6e23eb1a0ebb30e517cbcf91183afa24b99abee3',
|
|
|
'cookie': 'store-region=cn-gd; store-region-src=uid; is_staff_user=false; passport_csrf_token=4d1582c647abf363099fe8a4f975751e; passport_csrf_token_default=4d1582c647abf363099fe8a4f975751e; s_v_web_id=verify_m8fcj8us_JZLlXrhR_OZsr_42Uz_BjhU_sRduBwB5eG8l; n_mh=-Akptc0OjS9zIJQaCBO_o6uzJlp3wAItgZeldsCLFeU; sid_guard=6cda0bf1f5b9891a648e6193dbd4b600%7C1745982840%7C5184000%7CSun%2C+29-Jun-2025+03%3A14%3A00+GMT; uid_tt=b3bebe7098b5f11e07d1d5dd8238d822; uid_tt_ss=b3bebe7098b5f11e07d1d5dd8238d822; sid_tt=6cda0bf1f5b9891a648e6193dbd4b600; sessionid=6cda0bf1f5b9891a648e6193dbd4b600; sessionid_ss=6cda0bf1f5b9891a648e6193dbd4b600'
|
|
|
- }
|
|
|
+ },
|
|
|
+ // 添加额外的 axios 配置
|
|
|
+ timeout: 5000, // 5秒超时
|
|
|
+ validateStatus: function (status) {
|
|
|
+ return status >= 200 && status < 300; // 默认值
|
|
|
+ },
|
|
|
+ maxRedirects: 5
|
|
|
};
|
|
|
-
|
|
|
- // 构建查询参数
|
|
|
- const params = new URLSearchParams({
|
|
|
+
|
|
|
+ try {
|
|
|
+ const response = await axios(config);
|
|
|
+ if(response.data.code!=0){
|
|
|
+ throw response.data
|
|
|
+ }
|
|
|
+ if(response.data.data.length<=0){
|
|
|
+ throw response.data
|
|
|
+ }
|
|
|
+ return response.data.data[0];
|
|
|
+ } catch (error) {
|
|
|
+ if (error.response) {
|
|
|
+ // 服务器响应了,但状态码不在 2xx 范围内
|
|
|
+ console.error('Error Response:', error.response.data);
|
|
|
+ console.error('Error Status:', error.response.status);
|
|
|
+ console.error('Error Headers:', error.response.headers);
|
|
|
+ } else if (error.request) {
|
|
|
+ // 请求已经发出,但没有收到响应
|
|
|
+ console.error('Error Request:', error.request);
|
|
|
+ } else {
|
|
|
+ // 在设置请求时发生了错误
|
|
|
+ console.error('Error Message:', error.message);
|
|
|
+ }
|
|
|
+ return null
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+CMD.search_mf_new_id = async function(bookId){
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ const options = {
|
|
|
+ hostname: 'www.changdunovel.com',
|
|
|
+ path: '/novelsale/distributor/content/book/list/v1',
|
|
|
+ method: 'GET',
|
|
|
+ headers: {
|
|
|
+ 'accept': 'application/json, text/plain, */*',
|
|
|
+ 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
|
|
+ 'agw-js-conv': 'str',
|
|
|
+ 'appid': '40017687',
|
|
|
+ 'apptype': '15',
|
|
|
+ 'distributorid': '1819222136130603',
|
|
|
+ 'priority': 'u=1, i',
|
|
|
+ 'sec-ch-ua': '"Microsoft Edge";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
|
|
|
+ 'sec-ch-ua-mobile': '?1',
|
|
|
+ 'sec-ch-ua-platform': '"Android"',
|
|
|
+ 'sec-fetch-dest': 'empty',
|
|
|
+ 'sec-fetch-mode': 'cors',
|
|
|
+ 'sec-fetch-site': 'same-origin',
|
|
|
+ 'x-secsdk-csrf-token': '00010000000165946eed4d812d087c4148a726264fe223e04f1c6e23eb1a0ebb30e517cbcf91183afa24b99abee3',
|
|
|
+ 'cookie': 'store-region=cn-gd; store-region-src=uid; is_staff_user=false; passport_csrf_token=4d1582c647abf363099fe8a4f975751e; passport_csrf_token_default=4d1582c647abf363099fe8a4f975751e; s_v_web_id=verify_m8fcj8us_JZLlXrhR_OZsr_42Uz_BjhU_sRduBwB5eG8l; n_mh=-Akptc0OjS9zIJQaCBO_o6uzJlp3wAItgZeldsCLFeU; sid_guard=6cda0bf1f5b9891a648e6193dbd4b600%7C1745982840%7C5184000%7CSun%2C+29-Jun-2025+03%3A14%3A00+GMT; uid_tt=b3bebe7098b5f11e07d1d5dd8238d822; uid_tt_ss=b3bebe7098b5f11e07d1d5dd8238d822; sid_tt=6cda0bf1f5b9891a648e6193dbd4b600; sessionid=6cda0bf1f5b9891a648e6193dbd4b600; sessionid_ss=6cda0bf1f5b9891a648e6193dbd4b600'
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 构建查询参数
|
|
|
+ const params = new URLSearchParams({
|
|
|
permission_statuses: '3,4',
|
|
|
search_type: '6',
|
|
|
query: `${bookId}`,
|
|
@@ -156,29 +162,49 @@ CMD.search_mf_new_id = async function(bookId,call_back){
|
|
|
page_size: '1',
|
|
|
msToken: 'QtOXD1IEPGNjuwS8Lzzew68qWnqxmVU10gPxOLcbijTXMmshIe_toySxUmiovwVBez7c8O3QcscyRES2_uC',
|
|
|
a_bogus: 'mf0RheSEOx/nKpltmKsUeUHUEy2MrzuyDBTKRijyeNxpTZMaA8eeNOc9rxumZFaaeYpNZSMHUn-AznrcOcwwZ7HpKskvui7RtG9I98so8ZH3bBJg9r6MCGGoqkke/cWE85ltx9011UfO1nclk3dKMp3Jo/4qQODdRJ9zfPvax1q6640a7s8='
|
|
|
- });
|
|
|
-
|
|
|
- options.path += `?${params.toString()}`;
|
|
|
-
|
|
|
- const req = https.request(options, (res) => {
|
|
|
+ });
|
|
|
+
|
|
|
+ options.path += `?${params.toString()}`;
|
|
|
+
|
|
|
+ const req = https.request(options, (res) => {
|
|
|
let data = '';
|
|
|
-
|
|
|
+
|
|
|
res.on('data', (chunk) => {
|
|
|
- data += chunk;
|
|
|
+ data += chunk;
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
res.on('end', () => {
|
|
|
- console.log(JSON.parse(data));
|
|
|
- call_back(JSON.parse(data))
|
|
|
+ try {
|
|
|
+ const parsedData = JSON.parse(data);
|
|
|
+ if(parsedData.code!=0){
|
|
|
+ resolve(null);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(parsedData.data.length<=0){
|
|
|
+ resolve(null);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resolve(parsedData.data[0]);
|
|
|
+ } catch (e) {
|
|
|
+ console.error('JSON parsing error:', e);
|
|
|
+ reject(e);
|
|
|
+ }
|
|
|
});
|
|
|
- });
|
|
|
-
|
|
|
- req.on('error', (error) => {
|
|
|
- console.error(error);
|
|
|
- call_back(null)
|
|
|
- });
|
|
|
-
|
|
|
- req.end();
|
|
|
+ });
|
|
|
+
|
|
|
+ req.on('error', (error) => {
|
|
|
+ console.error('Request error:', error);
|
|
|
+ reject(error);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 设置请求超时
|
|
|
+ req.setTimeout(10000, () => {
|
|
|
+ req.destroy();
|
|
|
+ reject(new Error('Request timeout'));
|
|
|
+ });
|
|
|
+
|
|
|
+ req.end();
|
|
|
+});
|
|
|
}
|
|
|
|
|
|
module.exports = CMD;
|