@iflyrpa/actions 1.2.14-beta.1 → 1.2.14-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2,124 +2,32 @@ import * as __WEBPACK_EXTERNAL_MODULE_dom_serializer_aa70940b__ from "dom-serial
2
2
  import * as __WEBPACK_EXTERNAL_MODULE_domhandler__ from "domhandler";
3
3
  import * as __WEBPACK_EXTERNAL_MODULE_htmlparser2__ from "htmlparser2";
4
4
  import * as __WEBPACK_EXTERNAL_MODULE_mime_types_eebf54a5__ from "mime-types";
5
- import * as __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__ from "node:buffer";
6
- import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
7
5
  import * as __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__ from "@iflyrpa/share";
8
6
  import * as __WEBPACK_EXTERNAL_MODULE_axios__ from "axios";
9
7
  import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
10
8
  import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
11
9
  import * as __WEBPACK_EXTERNAL_MODULE_form_data_cf000082__ from "form-data";
10
+ import * as __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__ from "node:buffer";
11
+ import * as __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__ from "node:crypto";
12
12
  var __webpack_modules__ = {
13
- "./src/actions/searchAccountInfo/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
13
+ "./src/actions/searchAccountInfo/getWxInfo.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
14
14
  __webpack_require__.d(__webpack_exports__, {
15
- A: ()=>SearchAccountInfo
15
+ n: ()=>getWeixinData
16
16
  });
17
17
  var _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@iflyrpa/share");
18
- var _utils_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/utils/index.ts");
18
+ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/actions/searchAccountInfo/types.ts");
19
19
  var _utils_http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/utils/http.ts");
20
- var _utils_xhsXsEncrypt__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/xhsXsEncrypt.ts");
21
- const errorResponse = (message, code = 500)=>({
22
- code,
23
- message,
24
- data: null
25
- });
26
- async function getToutiaoData(params) {
27
- try {
28
- const http = new _utils_http__WEBPACK_IMPORTED_MODULE_2__.e({
29
- headers: {
30
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
31
- referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
32
- }
33
- });
34
- const [totalData, fansDataYesterday, contentDataYesterday] = await Promise.all([
35
- http.api({
36
- method: "get",
37
- url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
38
- params: {
39
- app_id: 1231
40
- }
41
- }),
42
- http.api({
43
- method: "get",
44
- url: "https://mp.toutiao.com/mp/agw/statistic/v2/fans/latest_stat",
45
- params: {
46
- app_id: 1231
47
- }
48
- }),
49
- http.api({
50
- method: "get",
51
- url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
52
- params: {
53
- type: 0,
54
- app_id: 1231
55
- }
56
- })
57
- ]);
58
- const ttData = {
59
- fansNum: Number(totalData.data.statistic.data.total_subscribe_count),
60
- fansNumYesterday: fansDataYesterday.fans_stat.change_count,
61
- readNum: Number(totalData.data.statistic.data.total_read_play_count),
62
- incomeNum: totalData.data.statistic.data.total_income,
63
- incomeNumYesterday: totalData.data.statistic.data.yesterday_income,
64
- showNumYesterday: contentDataYesterday.author_stat.consume_data.impression_count,
65
- readNumYesterday: contentDataYesterday.author_stat.consume_data.go_detail_count,
66
- likeNumYesterday: contentDataYesterday.author_stat.interaction_data.digg_count,
67
- commentNumYesterday: contentDataYesterday.author_stat.interaction_data.comment_count
68
- };
69
- return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(ttData, "头条号粉丝数据获取成功!");
70
- } catch (error) {
71
- return errorResponse(error instanceof Error ? error.message : "头条号数据获取失败");
72
- }
73
- }
74
- async function getXiaohongshuData(params) {
75
- try {
76
- const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
77
- if (!a1Cookie) return errorResponse("账号数据异常,请重新绑定账号后重试。", 200);
78
- const http = new _utils_http__WEBPACK_IMPORTED_MODULE_2__.e({
79
- headers: {
80
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
81
- referer: "https://creator.xiaohongshu.com",
82
- origin: "https://creator.xiaohongshu.com"
83
- }
84
- });
85
- const xsEncrypt = new _utils_xhsXsEncrypt__WEBPACK_IMPORTED_MODULE_3__.H();
86
- const xt = Date.now().toString();
87
- const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
88
- const xs = await xsEncrypt.encryptXs(sevenDataUrl, a1Cookie, xt);
89
- const [overAllData, sevenData] = await Promise.all([
90
- http.api({
91
- method: "get",
92
- url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
93
- }),
94
- http.api({
95
- method: "get",
96
- baseURL: "https://creator.xiaohongshu.com",
97
- url: sevenDataUrl,
98
- headers: {
99
- "x-s": xs,
100
- "x-t": xt
101
- }
102
- })
103
- ]);
104
- const xhsData = {
105
- fansNum: overAllData.data.fans_count,
106
- favedNum: overAllData.data.faved_count,
107
- watchNumLastWeek: sevenData.data.seven.view_count,
108
- likeNumLastWeek: sevenData.data.seven.like_count,
109
- collectNumLastWeek: sevenData.data.seven.collect_count,
110
- commentNumLastWeek: sevenData.data.seven.comment_count,
111
- fansNumLastWeek: sevenData.data.seven.rise_fans_count,
112
- fansNumYesterday: sevenData.data.seven.rise_fans_list[0].count
113
- };
114
- return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(xhsData, "小红书粉丝数据获取成功!");
115
- } catch (error) {
116
- return errorResponse(error instanceof Error ? error.message : "小红书数据获取失败");
117
- }
118
- }
20
+ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/utils/index.ts");
119
21
  async function getWeixinData(params) {
22
+ const { token } = params;
23
+ if (!token) return {
24
+ code: 200,
25
+ message: "缺少token",
26
+ data: null
27
+ };
120
28
  try {
121
29
  const { token } = params;
122
- if (!token) return errorResponse("缺少token", 200);
30
+ if (!token) return (0, _types__WEBPACK_IMPORTED_MODULE_1__.V)("缺少token", 200);
123
31
  const http = new _utils_http__WEBPACK_IMPORTED_MODULE_2__.e({
124
32
  headers: {
125
33
  cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
@@ -127,7 +35,7 @@ var __webpack_modules__ = {
127
35
  });
128
36
  const massRandomIDHtml = await http.api({
129
37
  method: "get",
130
- url: "https://mp.weixin.qq.com/misc/appmsganalysis?action=report&token=1900237878&lang=zh_CN",
38
+ url: "https://mp.weixin.qq.com/misc/appmsganalysis",
131
39
  params: {
132
40
  token,
133
41
  lang: "zh_CN",
@@ -157,11 +65,11 @@ var __webpack_modules__ = {
157
65
  const readAllList = arrays.readAllList || [];
158
66
  const shareAllList = arrays.shareAllList || [];
159
67
  const fansInfoReg = fansInfoHtml.match(/window\.CGI_DATA\['pages\/statistics\/user_statistics'\]\s*=\s*(\{[\s\S]*?\});/);
160
- if (!fansInfoReg) return errorResponse("未找到粉丝信息", 200);
68
+ if (!fansInfoReg) return (0, _types__WEBPACK_IMPORTED_MODULE_1__.V)("未找到粉丝信息", 200);
161
69
  const fansInfo = eval("(" + fansInfoReg[1] + ")");
162
- const yesterday = _utils_index__WEBPACK_IMPORTED_MODULE_1__.Tx.format(new Date().setDate(new Date().getDate() - 1), "yyyy-MM-dd");
70
+ const yesterday = _utils__WEBPACK_IMPORTED_MODULE_3__.Tx.format(new Date().setDate(new Date().getDate() - 1), "yyyy-MM-dd");
163
71
  const yesterdayFansInfo = fansInfo.list[0]?.list.find((item)=>item.date === yesterday);
164
- if (!yesterdayFansInfo) return errorResponse("未找到粉丝数", 200);
72
+ if (!yesterdayFansInfo) return (0, _types__WEBPACK_IMPORTED_MODULE_1__.V)("未找到粉丝数", 200);
165
73
  const wxData = {
166
74
  fansNum: yesterdayFansInfo.cumulate_user,
167
75
  fansNumYesterday: yesterdayFansInfo.new_user - yesterdayFansInfo.cancel_user,
@@ -170,70 +78,19 @@ var __webpack_modules__ = {
170
78
  };
171
79
  return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(wxData, "微信粉丝数据获取成功!");
172
80
  } catch (error) {
173
- return errorResponse(error instanceof Error ? error.message : "微信数据获取失败");
174
- }
175
- }
176
- async function getBaijiahaoData(params) {
177
- try {
178
- const { token } = params;
179
- if (!token) return errorResponse("缺少token", 200);
180
- const http = new _utils_http__WEBPACK_IMPORTED_MODULE_2__.e({
181
- headers: {
182
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
183
- token: String(token),
184
- Referer: "https://baijiahao.baidu.com/builder/rc/home"
185
- }
186
- });
187
- const yesterday = _utils_index__WEBPACK_IMPORTED_MODULE_1__.Tx.format(new Date().setDate(new Date().getDate() - 1), "yyyyMMdd");
188
- const [fansData, readData, incomeData, yesterdayData] = await Promise.all([
189
- http.api({
190
- method: "get",
191
- url: "https://baijiahao.baidu.com/pcui/home/index"
192
- }),
193
- http.api({
194
- method: "get",
195
- url: "https://baijiahao.baidu.com/author/eco/statistic/getauthorhistory"
196
- }),
197
- http.api({
198
- method: "get",
199
- url: "https://baijiahao.baidu.com/author/eco/income4/homepageincome"
200
- }),
201
- http.api({
202
- method: "get",
203
- url: `https://baijiahao.baidu.com/author/eco/statistics/appStatistic?type=all&is_yesterday=false&start_day=${yesterday}&end_day=${yesterday}&stat=0`
204
- })
205
- ]);
206
- const bjhData = {
207
- fansNum: fansData.data.coreData.fansCount,
208
- fansNumYesterday: yesterdayData.data.data.fans_increase,
209
- readNum: readData.data.total.view_count,
210
- incomeNum: incomeData.data.all_income.total_income,
211
- incomeNumYesterday: incomeData.data.all_income.yesterday_income,
212
- recommendNumYesterday: yesterdayData.data.data.recommend_count,
213
- readNumYesterday: yesterdayData.data.data.view_count,
214
- likeNumYesterday: yesterdayData.data.data.likes_count,
215
- commentNumYesterday: yesterdayData.data.data.comment_count
216
- };
217
- return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(bjhData, "百家号粉丝数据获取成功!");
218
- } catch (error) {
219
- return errorResponse(error instanceof Error ? error.message : "百家号数据获取失败");
81
+ return (0, _types__WEBPACK_IMPORTED_MODULE_1__.V)(error instanceof Error ? error.message : "微信数据获取失败");
220
82
  }
221
83
  }
222
- const SearchAccountInfo = async (_task, params)=>{
223
- const { platform } = params;
224
- switch(platform){
225
- case "toutiao":
226
- return getToutiaoData(params);
227
- case "xiaohongshu":
228
- return getXiaohongshuData(params);
229
- case "weixin":
230
- return getWeixinData(params);
231
- case "baijiahao":
232
- return getBaijiahaoData(params);
233
- default:
234
- return (0, _iflyrpa_share__WEBPACK_IMPORTED_MODULE_0__.success)(null, "暂不支持该平台");
235
- }
236
- };
84
+ },
85
+ "./src/actions/searchAccountInfo/types.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
86
+ __webpack_require__.d(__webpack_exports__, {
87
+ V: ()=>errorResponse
88
+ });
89
+ const errorResponse = (message, code = 500)=>({
90
+ code,
91
+ message,
92
+ data: null
93
+ });
237
94
  },
238
95
  "./src/utils/http.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
239
96
  __webpack_require__.d(__webpack_exports__, {
@@ -1594,61 +1451,6 @@ var __webpack_modules__ = {
1594
1451
  }
1595
1452
  module[a0_0x45db08(0xae)] = GenAB;
1596
1453
  },
1597
- "./src/utils/xhsXsEncrypt.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1598
- __webpack_require__.d(__webpack_exports__, {
1599
- H: ()=>XsEncrypt
1600
- });
1601
- class XsEncrypt {
1602
- async encryptMD5(url) {
1603
- return __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(url, "utf8").digest("hex");
1604
- }
1605
- async encryptText(text) {
1606
- const textEncoded = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(text).toString("base64");
1607
- const cipher = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
1608
- const ciphertext = cipher.update(textEncoded, "utf8", "base64");
1609
- return ciphertext + cipher.final("base64");
1610
- }
1611
- async base64ToHex(encodedData) {
1612
- const decodedData = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(encodedData, "base64");
1613
- return decodedData.toString("hex");
1614
- }
1615
- async encryptPayload(payload, platform) {
1616
- const hexPayload = await this.base64ToHex(payload);
1617
- const obj = {
1618
- signSvn: "56",
1619
- signType: "x2",
1620
- appID: platform,
1621
- signVersion: "1",
1622
- payload: hexPayload
1623
- };
1624
- const jsonString = JSON.stringify(obj, null, 0);
1625
- return __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(jsonString).toString("base64");
1626
- }
1627
- async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
1628
- const text = `x1=${await this.encryptMD5(`url=${url}`)};x2=0|0|0|1|0|0|1|0|0|0|1|0|0|0|0|1|0|0|0;x3=${a1};x4=${ts};`;
1629
- return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
1630
- }
1631
- dumps(...rest) {
1632
- const [data, replacer = null, space = 0] = rest;
1633
- return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
1634
- }
1635
- constructor(){
1636
- this.words = [
1637
- 929260340,
1638
- 1633971297,
1639
- 895580464,
1640
- 925905270
1641
- ];
1642
- this.keyBytes = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.concat(this.words.map((word)=>new Uint8Array(__WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from([
1643
- word >> 24 & 0xff,
1644
- word >> 16 & 0xff,
1645
- word >> 8 & 0xff,
1646
- 0xff & word
1647
- ]))));
1648
- this.iv = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from("4uzjr7mbsibcaldp", "utf8");
1649
- }
1650
- }
1651
- },
1652
1454
  "@iflyrpa/share": function(module) {
1653
1455
  module.exports = __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__;
1654
1456
  },
@@ -2950,280 +2752,528 @@ const BjhSessionCheck = async (_task, params)=>{
2950
2752
  }, "百家号账号有效性检测失败!");
2951
2753
  }
2952
2754
  };
2953
- var searchAccountInfo = __webpack_require__("./src/actions/searchAccountInfo/index.ts");
2954
- var xhsXsEncrypt = __webpack_require__("./src/utils/xhsXsEncrypt.ts");
2955
- const FetchArticles = async (_task, params)=>{
2956
- const { platform, cookies, token, pageNum = 1, pageSize = 10, onlySuccess = false, showOriginalData = false } = params;
2755
+ var types = __webpack_require__("./src/actions/searchAccountInfo/types.ts");
2756
+ async function getBaijiahaoData(params) {
2957
2757
  try {
2958
- switch(platform){
2959
- case "toutiao":
2960
- {
2961
- const http = new utils_http.e({
2962
- headers: {
2963
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2964
- }
2965
- });
2966
- const visitedUid = await http.api({
2967
- url: "https://mp.toutiao.com/mp/agw/creator_center/user_info?",
2968
- method: "get",
2969
- params: {
2970
- app_id: 1231
2971
- }
2972
- });
2973
- const articleInfo = await http.api({
2974
- method: "get",
2975
- url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
2976
- params: {
2977
- provider_type: "mp_provider",
2978
- aid: "13",
2979
- app_name: "news_article",
2980
- category: "mp_all",
2981
- channel: "",
2982
- stream_api_version: "88",
2983
- genre_type_switch: '{"repost":1,"small_video":1,"toutiao_graphic":1,"weitoutiao":1,"xigua_video":1}',
2984
- device_platform: "pc",
2985
- platform_id: "0",
2986
- visited_uid: visitedUid.user_id_str,
2987
- offset: (pageNum - 1) * pageSize,
2988
- count: pageSize,
2989
- keyword: "",
2990
- client_extra_params: `{"category":"mp_all","real_app_id":"1231","need_forward":"true","offset_mode":"1","page_index":"1","status":${onlySuccess ? "2" : "8"},"source":"0"}`,
2991
- app_id: "1231"
2992
- }
2993
- });
2994
- const articleCell = articleInfo.data.map((item)=>({
2995
- title: item.assembleCell.itemCell.articleBase.title,
2996
- imageUrl: item.assembleCell.itemCell.imageList.staggerFeedCover[0].url,
2997
- createTime: item.assembleCell.itemCell.articleBase.publishTime,
2998
- redirectUrl: item.assembleCell.itemCell.articleBase.articleURL,
2999
- showNum: item.assembleCell.itemCell.itemCounter.showCount,
3000
- readNum: item.assembleCell.itemCell.itemCounter.readCount,
3001
- likeNum: item.assembleCell.itemCell.itemCounter.diggCount,
3002
- commentNum: item.assembleCell.itemCell.itemCounter.commentCount,
3003
- ...showOriginalData ? {
3004
- originalData: item
3005
- } : {}
3006
- }));
3007
- const api_base_info_json = JSON.parse(articleInfo.api_base_info.app_extra_params);
3008
- return (0, share_.success)({
3009
- articleCell,
3010
- pagination: {
3011
- total: api_base_info_json.total_count,
3012
- pageNum,
3013
- pageSize
3014
- }
3015
- }, "头条号文章获取成功");
2758
+ const { token } = params;
2759
+ if (!token) return (0, types.V)("缺少token", 200);
2760
+ const http = new utils_http.e({
2761
+ headers: {
2762
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2763
+ token: String(token),
2764
+ Referer: "https://baijiahao.baidu.com/builder/rc/home"
2765
+ }
2766
+ });
2767
+ const yesterday = utils.Tx.format(new Date().setDate(new Date().getDate() - 1), "yyyyMMdd");
2768
+ const [fansData, readData, incomeData, yesterdayData] = await Promise.all([
2769
+ http.api({
2770
+ method: "get",
2771
+ url: "https://baijiahao.baidu.com/pcui/home/index"
2772
+ }),
2773
+ http.api({
2774
+ method: "get",
2775
+ url: "https://baijiahao.baidu.com/author/eco/statistic/getauthorhistory"
2776
+ }),
2777
+ http.api({
2778
+ method: "get",
2779
+ url: "https://baijiahao.baidu.com/author/eco/income4/homepageincome"
2780
+ }),
2781
+ http.api({
2782
+ method: "get",
2783
+ url: "https://baijiahao.baidu.com/author/eco/statistics/appStatistic",
2784
+ params: {
2785
+ type: "all",
2786
+ is_yesterday: false,
2787
+ start_day: yesterday,
2788
+ end_day: yesterday,
2789
+ stat: 0
3016
2790
  }
3017
- case "weixin":
3018
- {
3019
- if (!token) return {
3020
- code: 200,
3021
- message: "缺少token",
3022
- data: null
3023
- };
3024
- const http = new utils_http.e({
3025
- headers: {
3026
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
3027
- }
3028
- });
3029
- const ParsePublishPage = (body)=>{
3030
- const decodeHtml = (str)=>str.replace(/&quot;/g, '"').replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&#39;/g, "'").replace(/&nbsp;/g, ' ');
3031
- const match = body.match(/publish_page\s*=\s*(\{[\s\S]*?\})\s*;/);
3032
- if (!match) throw new Error('无法提取 publish_page 字段');
3033
- const rawPublishPageStr = match[1];
3034
- const parsedData = JSON.parse(rawPublishPageStr);
3035
- const finalData = {
3036
- ...parsedData,
3037
- publish_list: parsedData.publish_list.map((item)=>{
3038
- const decoded = decodeHtml(item.publish_info);
3039
- const parsedInfo = JSON.parse(decoded);
3040
- return {
3041
- publish_type: item.publish_type,
3042
- publish_info: parsedInfo
3043
- };
3044
- })
3045
- };
3046
- return finalData;
3047
- };
3048
- const rawArticlesInfo = await http.api({
3049
- method: "get",
3050
- url: 'https://mp.weixin.qq.com/cgi-bin/appmsgpublish?sub=list&begin=0&count=10&token=1453947575&lang=zh_CN',
3051
- params: {
3052
- sub: "list",
3053
- begin: (pageNum - 1) * pageSize,
3054
- count: pageSize,
3055
- token: token,
3056
- lang: "zh_CN"
3057
- }
3058
- });
3059
- const articlesInfo = ParsePublishPage(rawArticlesInfo);
3060
- const articleCell = articlesInfo?.publish_list.map((item)=>({
3061
- title: item.publish_info.appmsg_info[0].title,
3062
- imageUrl: item.publish_info.appmsg_info[0].cover,
3063
- createTime: item.publish_info.appmsg_info[0].line_info.send_time,
3064
- redirectUrl: item.publish_info.appmsg_info[0].content_url,
3065
- readNum: item.publish_info.appmsg_info[0].read_num,
3066
- likeNum: item.publish_info.appmsg_info[0].old_like_num,
3067
- shareNum: item.publish_info.appmsg_info[0].share_num,
3068
- recommendNum: item.publish_info.appmsg_info[0].like_num,
3069
- ...showOriginalData ? {
3070
- originalData: item
3071
- } : {}
3072
- }));
3073
- return (0, share_.success)({
3074
- articleCell,
3075
- ...onlySuccess ? {
3076
- pagination: {
3077
- total: articlesInfo?.total_count,
3078
- pageNum,
3079
- pageSize
3080
- }
3081
- } : null
3082
- }, "微信文章获取成功");
2791
+ })
2792
+ ]);
2793
+ const bjhData = {
2794
+ fansNum: fansData.data.coreData.fansCount,
2795
+ fansNumYesterday: yesterdayData.data.data.fans_increase,
2796
+ readNum: readData.data.total.view_count,
2797
+ incomeNum: incomeData.data.all_income.total_income,
2798
+ incomeNumYesterday: incomeData.data.all_income.yesterday_income,
2799
+ recommendNumYesterday: yesterdayData.data.data.recommend_count,
2800
+ readNumYesterday: yesterdayData.data.data.view_count,
2801
+ likeNumYesterday: yesterdayData.data.data.likes_count,
2802
+ commentNumYesterday: yesterdayData.data.data.comment_count
2803
+ };
2804
+ return (0, share_.success)(bjhData, "百家号粉丝数据获取成功!");
2805
+ } catch (error) {
2806
+ return (0, types.V)(error instanceof Error ? error.message : "百家号数据获取失败");
2807
+ }
2808
+ }
2809
+ async function getToutiaoData(params) {
2810
+ const { cookies } = params;
2811
+ try {
2812
+ const http = new utils_http.e({
2813
+ headers: {
2814
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2815
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
2816
+ }
2817
+ });
2818
+ const [totalData, fansDataYesterday, contentDataYesterday] = await Promise.all([
2819
+ http.api({
2820
+ method: "get",
2821
+ url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
2822
+ params: {
2823
+ app_id: 1231
3083
2824
  }
3084
- case "baijiahao":
3085
- {
3086
- if (!token) return {
3087
- code: 200,
3088
- message: "缺少token",
3089
- data: null
3090
- };
3091
- const http = new utils_http.e({
3092
- headers: {
3093
- cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3094
- token: token
3095
- }
3096
- });
3097
- async function fetchArticles(pageNum, pageSize, onlySuccess = false) {
3098
- return await http.api({
3099
- method: "get",
3100
- url: "https://baijiahao.baidu.com/pcui/article/lists",
3101
- params: {
3102
- currentPage: pageNum,
3103
- pageSize: pageSize,
3104
- search: "",
3105
- type: "",
3106
- collection: onlySuccess ? "publish" : "",
3107
- clearBeforeFetch: false,
3108
- dynamic: 1
3109
- }
3110
- });
3111
- }
3112
- const articleInfo = await fetchArticles(pageNum, pageSize, onlySuccess);
3113
- let filtered = articleInfo.data.list.filter((item)=>"draft" !== item.status);
3114
- const totalPage = articleInfo.data.page?.totalPage || 1;
3115
- let currentPage = pageNum + 1;
3116
- const usedPages = new Set();
3117
- while(filtered.length < pageSize && currentPage <= totalPage){
3118
- if (usedPages.has(currentPage)) {
3119
- currentPage++;
3120
- continue;
3121
- }
3122
- const res = await fetchArticles(currentPage, pageSize, onlySuccess);
3123
- usedPages.add(currentPage);
3124
- const validItems = res.data.list.filter((item)=>"draft" !== item.status);
3125
- filtered.push(...validItems);
3126
- currentPage++;
3127
- }
3128
- const final = filtered.slice(0, pageSize);
3129
- const articleCell = final.map((item)=>({
3130
- title: item.title,
3131
- imageUrl: JSON.parse(item.cover_images)[0].src,
3132
- createTime: Math.floor(new Date(item.publish_at.replace(/-/g, "/")).getTime() / 1000),
3133
- redirectUrl: item.url,
3134
- recommendNum: item.rec_amount,
3135
- collectNum: item.collection_amount,
3136
- readNum: item.read_amount,
3137
- likeNum: item.like_amount,
3138
- commentNum: item.comment_amount,
3139
- shareNum: item.share_amount,
3140
- ...showOriginalData ? {
3141
- originalData: item
3142
- } : {}
3143
- }));
3144
- return (0, share_.success)({
3145
- articleCell,
3146
- ...onlySuccess ? {
3147
- pagination: {
3148
- total: articleInfo.data.page?.totalCount,
3149
- pageNum,
3150
- pageSize
3151
- }
3152
- } : null
3153
- }, "百家号文章获取成功");
2825
+ }),
2826
+ http.api({
2827
+ method: "get",
2828
+ url: "https://mp.toutiao.com/mp/agw/statistic/v2/fans/latest_stat",
2829
+ params: {
2830
+ app_id: 1231
3154
2831
  }
3155
- case "xiaohongshu":
3156
- {
3157
- const xsEncrypt = new xhsXsEncrypt.H();
3158
- const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
3159
- if (!a1Cookie) return {
3160
- code: 200,
3161
- message: "账号数据异常",
3162
- data: null
3163
- };
3164
- if (10 != pageSize) return {
3165
- code: 200,
3166
- message: "小红书pageSize不可修改",
3167
- data: null
2832
+ }),
2833
+ http.api({
2834
+ method: "get",
2835
+ url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
2836
+ params: {
2837
+ type: 0,
2838
+ app_id: 1231
2839
+ }
2840
+ })
2841
+ ]);
2842
+ const ttData = {
2843
+ fansNum: Number(totalData.data.statistic.data.total_subscribe_count),
2844
+ fansNumYesterday: fansDataYesterday.fans_stat.change_count,
2845
+ readNum: Number(totalData.data.statistic.data.total_read_play_count),
2846
+ incomeNum: totalData.data.statistic.data.total_income,
2847
+ incomeNumYesterday: totalData.data.statistic.data.yesterday_income,
2848
+ showNumYesterday: contentDataYesterday.author_stat.consume_data.impression_count,
2849
+ readNumYesterday: contentDataYesterday.author_stat.consume_data.go_detail_count,
2850
+ likeNumYesterday: contentDataYesterday.author_stat.interaction_data.digg_count,
2851
+ commentNumYesterday: contentDataYesterday.author_stat.interaction_data.comment_count
2852
+ };
2853
+ return (0, share_.success)(ttData, "头条号粉丝数据获取成功!");
2854
+ } catch (error) {
2855
+ return (0, types.V)(error instanceof Error ? error.message : "头条号数据获取失败");
2856
+ }
2857
+ }
2858
+ var getWxInfo = __webpack_require__("./src/actions/searchAccountInfo/getWxInfo.ts");
2859
+ class XsEncrypt {
2860
+ async encryptMD5(url) {
2861
+ return __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(url, "utf8").digest("hex");
2862
+ }
2863
+ async encryptText(text) {
2864
+ const textEncoded = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(text).toString("base64");
2865
+ const cipher = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
2866
+ const ciphertext = cipher.update(textEncoded, "utf8", "base64");
2867
+ return ciphertext + cipher.final("base64");
2868
+ }
2869
+ async base64ToHex(encodedData) {
2870
+ const decodedData = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(encodedData, "base64");
2871
+ return decodedData.toString("hex");
2872
+ }
2873
+ async encryptPayload(payload, platform) {
2874
+ const hexPayload = await this.base64ToHex(payload);
2875
+ const obj = {
2876
+ signSvn: "56",
2877
+ signType: "x2",
2878
+ appID: platform,
2879
+ signVersion: "1",
2880
+ payload: hexPayload
2881
+ };
2882
+ const jsonString = JSON.stringify(obj, null, 0);
2883
+ return __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from(jsonString).toString("base64");
2884
+ }
2885
+ async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
2886
+ const text = `x1=${await this.encryptMD5(`url=${url}`)};x2=0|0|0|1|0|0|1|0|0|0|1|0|0|0|0|1|0|0|0;x3=${a1};x4=${ts};`;
2887
+ return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
2888
+ }
2889
+ dumps(...rest) {
2890
+ const [data, replacer = null, space = 0] = rest;
2891
+ return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
2892
+ }
2893
+ constructor(){
2894
+ this.words = [
2895
+ 929260340,
2896
+ 1633971297,
2897
+ 895580464,
2898
+ 925905270
2899
+ ];
2900
+ this.keyBytes = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.concat(this.words.map((word)=>new Uint8Array(__WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from([
2901
+ word >> 24 & 0xff,
2902
+ word >> 16 & 0xff,
2903
+ word >> 8 & 0xff,
2904
+ 0xff & word
2905
+ ]))));
2906
+ this.iv = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from("4uzjr7mbsibcaldp", "utf8");
2907
+ }
2908
+ }
2909
+ async function getXiaohongshuData(params) {
2910
+ try {
2911
+ const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
2912
+ if (!a1Cookie) return (0, types.V)("账号数据异常,请重新绑定账号后重试。", 200);
2913
+ const http = new utils_http.e({
2914
+ headers: {
2915
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2916
+ referer: "https://creator.xiaohongshu.com",
2917
+ origin: "https://creator.xiaohongshu.com"
2918
+ }
2919
+ });
2920
+ const xsEncrypt = new XsEncrypt();
2921
+ const xt = Date.now().toString();
2922
+ const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
2923
+ const xs = await xsEncrypt.encryptXs(sevenDataUrl, a1Cookie, xt);
2924
+ const [overAllData, sevenData] = await Promise.all([
2925
+ http.api({
2926
+ method: "get",
2927
+ url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
2928
+ }),
2929
+ http.api({
2930
+ method: "get",
2931
+ baseURL: "https://creator.xiaohongshu.com",
2932
+ url: sevenDataUrl,
2933
+ headers: {
2934
+ "x-s": xs,
2935
+ "x-t": xt
2936
+ }
2937
+ })
2938
+ ]);
2939
+ const xhsData = {
2940
+ fansNum: overAllData.data.fans_count,
2941
+ favedNum: overAllData.data.faved_count,
2942
+ watchNumLastWeek: sevenData.data.seven.view_count,
2943
+ likeNumLastWeek: sevenData.data.seven.like_count,
2944
+ collectNumLastWeek: sevenData.data.seven.collect_count,
2945
+ commentNumLastWeek: sevenData.data.seven.comment_count,
2946
+ fansNumLastWeek: sevenData.data.seven.rise_fans_count,
2947
+ fansNumYesterday: sevenData.data.seven.rise_fans_list[0].count
2948
+ };
2949
+ return (0, share_.success)(xhsData, "小红书粉丝数据获取成功!");
2950
+ } catch (error) {
2951
+ return (0, types.V)(error instanceof Error ? error.message : "小红书数据获取失败");
2952
+ }
2953
+ }
2954
+ const SearchAccountInfo = async (_task, params)=>{
2955
+ const { platform } = params;
2956
+ switch(platform){
2957
+ case "toutiao":
2958
+ return getToutiaoData(params);
2959
+ case "xiaohongshu":
2960
+ return getXiaohongshuData(params);
2961
+ case "weixin":
2962
+ return (0, getWxInfo.n)(params);
2963
+ case "baijiahao":
2964
+ return getBaijiahaoData(params);
2965
+ default:
2966
+ return (0, share_.success)(null, "暂不支持该平台");
2967
+ }
2968
+ };
2969
+ const errorResponse = (message, code = 500)=>({
2970
+ code,
2971
+ message,
2972
+ data: null
2973
+ });
2974
+ async function handleToutiaoData(params) {
2975
+ try {
2976
+ const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
2977
+ const http = new utils_http.e({
2978
+ headers: {
2979
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2980
+ }
2981
+ });
2982
+ const visitedUid = await http.api({
2983
+ url: "https://mp.toutiao.com/mp/agw/creator_center/user_info?",
2984
+ method: "get",
2985
+ params: {
2986
+ app_id: 1231
2987
+ }
2988
+ });
2989
+ const articleInfo = await http.api({
2990
+ method: "get",
2991
+ url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
2992
+ params: {
2993
+ provider_type: "mp_provider",
2994
+ aid: "13",
2995
+ app_name: "news_article",
2996
+ category: "mp_all",
2997
+ channel: "",
2998
+ stream_api_version: "88",
2999
+ genre_type_switch: '{"repost":1,"small_video":1,"toutiao_graphic":1,"weitoutiao":1,"xigua_video":1}',
3000
+ device_platform: "pc",
3001
+ platform_id: "0",
3002
+ visited_uid: visitedUid.user_id_str,
3003
+ offset: (pageNum - 1) * pageSize,
3004
+ count: pageSize,
3005
+ keyword: "",
3006
+ client_extra_params: `{"category":"mp_all","real_app_id":"1231","need_forward":"true","offset_mode":"1","page_index":"1","status":${onlySuccess ? "2" : "8"},"source":"0"}`,
3007
+ app_id: "1231"
3008
+ }
3009
+ });
3010
+ const articleCell = articleInfo.data.map((item)=>({
3011
+ title: item.assembleCell.itemCell.articleBase.title,
3012
+ imageUrl: item.assembleCell.itemCell.imageList.staggerFeedCover[0].url,
3013
+ createTime: item.assembleCell.itemCell.articleBase.publishTime,
3014
+ redirectUrl: item.assembleCell.itemCell.articleBase.articleURL,
3015
+ showNum: item.assembleCell.itemCell.itemCounter.showCount,
3016
+ readNum: item.assembleCell.itemCell.itemCounter.readCount,
3017
+ likeNum: item.assembleCell.itemCell.itemCounter.diggCount,
3018
+ commentNum: item.assembleCell.itemCell.itemCounter.commentCount,
3019
+ ...showOriginalData ? {
3020
+ originalData: item
3021
+ } : {}
3022
+ }));
3023
+ const api_base_info_json = JSON.parse(articleInfo.api_base_info.app_extra_params);
3024
+ return (0, share_.success)({
3025
+ articleCell,
3026
+ pagination: {
3027
+ total: api_base_info_json.total_count,
3028
+ pageNum,
3029
+ pageSize
3030
+ }
3031
+ }, "头条号文章获取成功");
3032
+ } catch (error) {
3033
+ return errorResponse(error instanceof Error ? error.message : "头条号数据获取失败");
3034
+ }
3035
+ }
3036
+ async function handleWeixinData(params) {
3037
+ try {
3038
+ const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3039
+ if (!token) return {
3040
+ code: 200,
3041
+ message: "缺少token",
3042
+ data: null
3043
+ };
3044
+ const http = new utils_http.e({
3045
+ headers: {
3046
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
3047
+ }
3048
+ });
3049
+ const ParsePublishPage = (body)=>{
3050
+ const decodeHtml = (str)=>str.replace(/&quot;/g, '"').replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&#39;/g, "'").replace(/&nbsp;/g, ' ');
3051
+ const match = body.match(/publish_page\s*=\s*(\{[\s\S]*?\})\s*;/);
3052
+ if (!match) throw new Error('无法提取 publish_page 字段');
3053
+ const rawPublishPageStr = match[1];
3054
+ const parsedData = JSON.parse(rawPublishPageStr);
3055
+ const finalData = {
3056
+ ...parsedData,
3057
+ publish_list: parsedData.publish_list.map((item)=>{
3058
+ const decoded = decodeHtml(item.publish_info);
3059
+ const parsedInfo = JSON.parse(decoded);
3060
+ return {
3061
+ publish_type: item.publish_type,
3062
+ publish_info: parsedInfo
3168
3063
  };
3169
- const http = new utils_http.e({
3170
- headers: {
3171
- cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3172
- referer: "https://creator.xiaohongshu.com",
3173
- origin: "https://creator.xiaohongshu.com"
3174
- }
3175
- });
3176
- const xt = Date.now().toString();
3177
- const serveUrl = `/web_api/sns/v5/creator/note/user/posted?tab=${onlySuccess ? 1 : 0}&page=${pageNum - 1}`;
3178
- const xs = await xsEncrypt.encryptXs(serveUrl, a1Cookie, xt);
3179
- const articleInfo = await http.api({
3180
- method: "get",
3181
- baseURL: "https://edith.xiaohongshu.com",
3182
- url: serveUrl,
3183
- headers: {
3184
- "x-s": xs,
3185
- "x-t": xt
3186
- }
3187
- });
3188
- const articleCell = articleInfo.data.notes.map((item)=>({
3189
- title: item.display_title,
3190
- imageUrl: item.images_list[0].url,
3191
- createTime: Math.floor(new Date(item.time.replace(/-/g, "/")).getTime() / 1000),
3192
- redirectUrl: `https://www.xiaohongshu.com/explore/${item.id}?xsec_token=${item.xsec_token}&xsec_source=pc_creatormng`,
3193
- readNum: item.view_count,
3194
- likeNum: item.likes,
3195
- commentNum: item.comments_count,
3196
- collectNum: item.collected_count,
3197
- shareNum: item.shared_count,
3198
- ...showOriginalData ? {
3199
- originalData: item
3200
- } : {}
3201
- }));
3202
- return (0, share_.success)({
3203
- articleCell,
3204
- ...onlySuccess ? {
3205
- pagination: {
3206
- total: articleInfo.data.tags[0].notes_count,
3207
- pageNum,
3208
- pageSize
3209
- }
3210
- } : null
3211
- }, "小红书文章获取成功");
3064
+ })
3065
+ };
3066
+ return finalData;
3067
+ };
3068
+ const rawArticlesInfo = await http.api({
3069
+ method: "get",
3070
+ url: 'https://mp.weixin.qq.com/cgi-bin/appmsgpublish',
3071
+ params: {
3072
+ sub: "list",
3073
+ begin: (pageNum - 1) * pageSize,
3074
+ count: pageSize,
3075
+ token: token,
3076
+ lang: "zh_CN"
3077
+ }
3078
+ });
3079
+ const articlesInfo = ParsePublishPage(rawArticlesInfo);
3080
+ const articleCell = articlesInfo?.publish_list.map((item)=>({
3081
+ title: item.publish_info.appmsg_info[0].title,
3082
+ imageUrl: item.publish_info.appmsg_info[0].cover,
3083
+ createTime: item.publish_info.appmsg_info[0].line_info.send_time,
3084
+ redirectUrl: item.publish_info.appmsg_info[0].content_url,
3085
+ readNum: item.publish_info.appmsg_info[0].read_num,
3086
+ likeNum: item.publish_info.appmsg_info[0].old_like_num,
3087
+ shareNum: item.publish_info.appmsg_info[0].share_num,
3088
+ recommendNum: item.publish_info.appmsg_info[0].like_num,
3089
+ ...showOriginalData ? {
3090
+ originalData: item
3091
+ } : {}
3092
+ }));
3093
+ return (0, share_.success)({
3094
+ articleCell,
3095
+ ...onlySuccess ? {
3096
+ pagination: {
3097
+ total: articlesInfo?.total_count,
3098
+ pageNum,
3099
+ pageSize
3212
3100
  }
3213
- default:
3214
- return {
3215
- code: 200,
3216
- message: "暂不支持该平台",
3217
- data: null
3218
- };
3101
+ } : null
3102
+ }, "微信文章获取成功");
3103
+ } catch (error) {
3104
+ return errorResponse(error instanceof Error ? error.message : "微信数据获取失败");
3105
+ }
3106
+ }
3107
+ async function handleBaijiahaoData(params) {
3108
+ try {
3109
+ const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3110
+ if (!token) return {
3111
+ code: 200,
3112
+ message: "缺少token",
3113
+ data: null
3114
+ };
3115
+ const http = new utils_http.e({
3116
+ headers: {
3117
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3118
+ token: token
3119
+ }
3120
+ });
3121
+ async function fetchArticles(pageNum, pageSize, onlySuccess = false) {
3122
+ return await http.api({
3123
+ method: "get",
3124
+ url: "https://baijiahao.baidu.com/pcui/article/lists",
3125
+ params: {
3126
+ currentPage: pageNum,
3127
+ pageSize: pageSize,
3128
+ search: "",
3129
+ type: "",
3130
+ collection: onlySuccess ? "publish" : "",
3131
+ clearBeforeFetch: false,
3132
+ dynamic: 1
3133
+ }
3134
+ });
3135
+ }
3136
+ const articleInfo = await fetchArticles(pageNum, pageSize, onlySuccess);
3137
+ let filtered = articleInfo.data.list.filter((item)=>"draft" !== item.status);
3138
+ const totalPage = articleInfo.data.page?.totalPage || 1;
3139
+ let currentPage = pageNum + 1;
3140
+ const usedPages = new Set();
3141
+ while(filtered.length < pageSize && currentPage <= totalPage){
3142
+ if (usedPages.has(currentPage)) {
3143
+ currentPage++;
3144
+ continue;
3145
+ }
3146
+ const res = await fetchArticles(currentPage, pageSize, onlySuccess);
3147
+ usedPages.add(currentPage);
3148
+ const validItems = res.data.list.filter((item)=>"draft" !== item.status);
3149
+ filtered.push(...validItems);
3150
+ currentPage++;
3219
3151
  }
3152
+ const final = filtered.slice(0, pageSize);
3153
+ const articleCell = final.map((item)=>({
3154
+ title: item.title,
3155
+ imageUrl: JSON.parse(item.cover_images)[0].src,
3156
+ createTime: Math.floor(new Date(item.publish_at.replace(/-/g, "/")).getTime() / 1000),
3157
+ redirectUrl: item.url,
3158
+ recommendNum: item.rec_amount,
3159
+ collectNum: item.collection_amount,
3160
+ readNum: item.read_amount,
3161
+ likeNum: item.like_amount,
3162
+ commentNum: item.comment_amount,
3163
+ shareNum: item.share_amount,
3164
+ ...showOriginalData ? {
3165
+ originalData: item
3166
+ } : {}
3167
+ }));
3168
+ return (0, share_.success)({
3169
+ articleCell,
3170
+ ...onlySuccess ? {
3171
+ pagination: {
3172
+ total: articleInfo.data.page?.totalCount,
3173
+ pageNum,
3174
+ pageSize
3175
+ }
3176
+ } : null
3177
+ }, "百家号文章获取成功");
3220
3178
  } catch (error) {
3221
- console.error("获取文章数据失败:", error);
3222
- return {
3223
- code: 500,
3224
- message: "获取文章数据失败",
3179
+ return errorResponse(error instanceof Error ? error.message : "百家号数据获取失败");
3180
+ }
3181
+ }
3182
+ async function handleXiaohongshuData(params) {
3183
+ try {
3184
+ const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3185
+ const xsEncrypt = new XsEncrypt();
3186
+ const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
3187
+ if (!a1Cookie) return {
3188
+ code: 200,
3189
+ message: "账号数据异常",
3225
3190
  data: null
3226
3191
  };
3192
+ if (onlySuccess && 10 != pageSize) return {
3193
+ code: 200,
3194
+ message: "小红书pageSize不可修改",
3195
+ data: null
3196
+ };
3197
+ const http = new utils_http.e({
3198
+ headers: {
3199
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3200
+ referer: "https://creator.xiaohongshu.com",
3201
+ origin: "https://creator.xiaohongshu.com"
3202
+ }
3203
+ });
3204
+ async function fetchArticles(pageNum, a1Cookie, onlySuccess = false) {
3205
+ const xt = Date.now().toString();
3206
+ const serveUrl = `/web_api/sns/v5/creator/note/user/posted?tab=${onlySuccess ? 1 : 0}&page=${pageNum - 1}`;
3207
+ const xs = await xsEncrypt.encryptXs(serveUrl, a1Cookie, xt);
3208
+ return await http.api({
3209
+ method: "get",
3210
+ baseURL: "https://edith.xiaohongshu.com",
3211
+ url: serveUrl,
3212
+ headers: {
3213
+ "x-s": xs,
3214
+ "x-t": xt
3215
+ }
3216
+ });
3217
+ }
3218
+ const articleInfo = await fetchArticles(pageNum, a1Cookie, onlySuccess);
3219
+ let hasNextpage = -1 != articleInfo.data.page;
3220
+ let filtered = articleInfo.data.notes;
3221
+ let currentPage = pageNum + 1;
3222
+ const usedPages = new Set();
3223
+ while(filtered.length < pageSize && hasNextpage){
3224
+ if (usedPages.has(currentPage)) {
3225
+ currentPage++;
3226
+ continue;
3227
+ }
3228
+ const res = await fetchArticles(currentPage, a1Cookie, onlySuccess);
3229
+ usedPages.add(currentPage);
3230
+ const validItems = res.data.notes;
3231
+ filtered.push(...validItems);
3232
+ currentPage++;
3233
+ hasNextpage = -1 != res.data.page;
3234
+ }
3235
+ const final = filtered.slice(0, pageSize);
3236
+ const articleCell = final.map((item)=>({
3237
+ title: item.display_title,
3238
+ imageUrl: item.images_list[0].url,
3239
+ createTime: Math.floor(new Date(item.time.replace(/-/g, "/")).getTime() / 1000),
3240
+ redirectUrl: `https://www.xiaohongshu.com/explore/${item.id}?xsec_token=${item.xsec_token}&xsec_source=pc_creatormng`,
3241
+ readNum: item.view_count,
3242
+ likeNum: item.likes,
3243
+ commentNum: item.comments_count,
3244
+ collectNum: item.collected_count,
3245
+ shareNum: item.shared_count,
3246
+ ...showOriginalData ? {
3247
+ originalData: item
3248
+ } : {}
3249
+ }));
3250
+ return (0, share_.success)({
3251
+ articleCell,
3252
+ ...onlySuccess ? {
3253
+ pagination: {
3254
+ total: articleInfo.data.tags[0]?.notes_count || -1,
3255
+ pageNum,
3256
+ pageSize
3257
+ }
3258
+ } : null
3259
+ }, "小红书文章获取成功");
3260
+ } catch (error) {
3261
+ return errorResponse(error instanceof Error ? error.message : "小红书数据获取失败");
3262
+ }
3263
+ }
3264
+ const FetchArticles = async (_task, params)=>{
3265
+ const { platform } = params;
3266
+ switch(platform){
3267
+ case "toutiao":
3268
+ return handleToutiaoData(params);
3269
+ case "weixin":
3270
+ return handleWeixinData(params);
3271
+ case "baijiahao":
3272
+ return handleBaijiahaoData(params);
3273
+ case "xiaohongshu":
3274
+ return handleXiaohongshuData(params);
3275
+ default:
3276
+ return (0, share_.success)(null, "暂不支持该平台");
3227
3277
  }
3228
3278
  };
3229
3279
  const getWeixinConfig = async (_task, params)=>{
@@ -4778,7 +4828,7 @@ const xiaohongshuPublish_mock_errnoMap = {
4778
4828
  903: "账户已登出,需重新登陆重试!",
4779
4829
  902: "登录已过期,请重新登录!"
4780
4830
  };
4781
- const mock_xsEncrypt = new xhsXsEncrypt.H();
4831
+ const mock_xsEncrypt = new XsEncrypt();
4782
4832
  const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
4783
4833
  const tmpCachePath = task.getTmpPath();
4784
4834
  const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
@@ -4967,7 +5017,7 @@ const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
4967
5017
  });
4968
5018
  return (0, share_.success)(publishResult.data?.id);
4969
5019
  };
4970
- const rpa_xsEncrypt = new xhsXsEncrypt.H();
5020
+ const rpa_xsEncrypt = new XsEncrypt();
4971
5021
  const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
4972
5022
  const commonCookies = {
4973
5023
  path: "/",
@@ -5182,7 +5232,7 @@ const xiaohongshuPublish = async (task, params)=>{
5182
5232
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
5183
5233
  return (0, utils.jo)(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
5184
5234
  };
5185
- var package_namespaceObject = JSON.parse('{"i8":"1.2.14-beta.0"}');
5235
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.14-beta.1"}');
5186
5236
  class Action {
5187
5237
  constructor(task){
5188
5238
  this.task = task;
@@ -5207,7 +5257,7 @@ class Action {
5207
5257
  return this.bindTask(FetchArticles, params);
5208
5258
  }
5209
5259
  SearchAccountInfo(params) {
5210
- return this.bindTask(searchAccountInfo.A, params);
5260
+ return this.bindTask(SearchAccountInfo, params);
5211
5261
  }
5212
5262
  TTSessionCheck(params) {
5213
5263
  return this.bindTask(TTSessionCheck, params);