@iflyrpa/actions 1.2.14 → 1.2.16-beta.0
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/actions/common/FansTool/index.d.ts +3 -9
- package/dist/actions/common/sessionCheck/index.d.ts +16 -0
- package/dist/actions/getBaijiaohaoConfig/index.d.ts +1 -0
- package/dist/actions/getWeixinConfig/index.d.ts +16 -0
- package/dist/actions/searchAccountInfo/getBjhInfo.d.ts +3 -0
- package/dist/actions/searchAccountInfo/getTTInfo.d.ts +3 -0
- package/dist/actions/searchAccountInfo/getWxInfo.d.ts +3 -0
- package/dist/actions/searchAccountInfo/getXhsInfo.d.ts +3 -0
- package/dist/actions/searchAccountInfo/index.d.ts +8 -0
- package/dist/actions/searchAccountInfo/types.d.ts +44 -0
- package/dist/actions/searchPublishInfo/handleBjhData.d.ts +3 -0
- package/dist/actions/searchPublishInfo/handleTTData.d.ts +3 -0
- package/dist/actions/searchPublishInfo/handleWXData.d.ts +3 -0
- package/dist/actions/searchPublishInfo/handleXhsData.d.ts +3 -0
- package/dist/actions/searchPublishInfo/index.d.ts +13 -0
- package/dist/actions/searchPublishInfo/types.d.ts +50 -0
- package/dist/actions/xiaohongshuPublish/mock.d.ts +1 -1
- package/dist/bundle.js +888 -92
- package/dist/bundle.js.map +1 -1
- package/dist/index.d.ts +15 -6
- package/dist/index.js +886 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +883 -87
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1859,12 +1859,20 @@ var __webpack_exports__ = {};
|
|
|
1859
1859
|
type: "news"
|
|
1860
1860
|
}
|
|
1861
1861
|
});
|
|
1862
|
-
|
|
1862
|
+
const data = res?.data?.article.activity_list.map((_item)=>({
|
|
1863
1863
|
id: _item.id,
|
|
1864
1864
|
name: _item.name,
|
|
1865
1865
|
detail: _item.detail,
|
|
1866
1866
|
is_enable: _item.is_enable
|
|
1867
|
-
})) ?? []
|
|
1867
|
+
})) ?? [];
|
|
1868
|
+
data.push({
|
|
1869
|
+
id: "bjh_publish_num_left",
|
|
1870
|
+
name: "账号剩余发文数",
|
|
1871
|
+
detail: "",
|
|
1872
|
+
is_enable: 1,
|
|
1873
|
+
publish_num_left: res.data.ability.publish_num_left
|
|
1874
|
+
});
|
|
1875
|
+
return (0, share_namespaceObject.success)(data, "获取百家号配置项成功!");
|
|
1868
1876
|
};
|
|
1869
1877
|
const searchToutiaoTopicList = async (_task, params)=>{
|
|
1870
1878
|
const http = new Http({
|
|
@@ -1981,6 +1989,60 @@ var __webpack_exports__ = {};
|
|
|
1981
1989
|
return (0, share_namespaceObject.success)([]);
|
|
1982
1990
|
}
|
|
1983
1991
|
};
|
|
1992
|
+
const external_node_buffer_namespaceObject = require("node:buffer");
|
|
1993
|
+
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
1994
|
+
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
1995
|
+
class XsEncrypt {
|
|
1996
|
+
async encryptMD5(url) {
|
|
1997
|
+
return external_node_crypto_default().createHash("md5").update(url, "utf8").digest("hex");
|
|
1998
|
+
}
|
|
1999
|
+
async encryptText(text) {
|
|
2000
|
+
const textEncoded = external_node_buffer_namespaceObject.Buffer.from(text).toString("base64");
|
|
2001
|
+
const cipher = external_node_crypto_default().createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
|
|
2002
|
+
const ciphertext = cipher.update(textEncoded, "utf8", "base64");
|
|
2003
|
+
return ciphertext + cipher.final("base64");
|
|
2004
|
+
}
|
|
2005
|
+
async base64ToHex(encodedData) {
|
|
2006
|
+
const decodedData = external_node_buffer_namespaceObject.Buffer.from(encodedData, "base64");
|
|
2007
|
+
return decodedData.toString("hex");
|
|
2008
|
+
}
|
|
2009
|
+
async encryptPayload(payload, platform) {
|
|
2010
|
+
const hexPayload = await this.base64ToHex(payload);
|
|
2011
|
+
const obj = {
|
|
2012
|
+
signSvn: "56",
|
|
2013
|
+
signType: "x2",
|
|
2014
|
+
appID: platform,
|
|
2015
|
+
signVersion: "1",
|
|
2016
|
+
payload: hexPayload
|
|
2017
|
+
};
|
|
2018
|
+
const jsonString = JSON.stringify(obj, null, 0);
|
|
2019
|
+
return external_node_buffer_namespaceObject.Buffer.from(jsonString).toString("base64");
|
|
2020
|
+
}
|
|
2021
|
+
async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
|
|
2022
|
+
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};`;
|
|
2023
|
+
return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
|
|
2024
|
+
}
|
|
2025
|
+
dumps(...rest) {
|
|
2026
|
+
const [data, replacer = null, space = 0] = rest;
|
|
2027
|
+
return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
|
|
2028
|
+
}
|
|
2029
|
+
constructor(){
|
|
2030
|
+
this.words = [
|
|
2031
|
+
929260340,
|
|
2032
|
+
1633971297,
|
|
2033
|
+
895580464,
|
|
2034
|
+
925905270
|
|
2035
|
+
];
|
|
2036
|
+
this.keyBytes = external_node_buffer_namespaceObject.Buffer.concat(this.words.map((word)=>new Uint8Array(external_node_buffer_namespaceObject.Buffer.from([
|
|
2037
|
+
word >> 24 & 0xff,
|
|
2038
|
+
word >> 16 & 0xff,
|
|
2039
|
+
word >> 8 & 0xff,
|
|
2040
|
+
0xff & word
|
|
2041
|
+
]))));
|
|
2042
|
+
this.iv = external_node_buffer_namespaceObject.Buffer.from("4uzjr7mbsibcaldp", "utf8");
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
const searchXiaohongshuTopicList_xsEncrypt = new XsEncrypt();
|
|
1984
2046
|
const searchXiaohongshuTopicList = async (_task, params)=>{
|
|
1985
2047
|
const http = new Http({
|
|
1986
2048
|
headers: {
|
|
@@ -1989,20 +2051,35 @@ var __webpack_exports__ = {};
|
|
|
1989
2051
|
origin: "https://creator.xiaohongshu.com"
|
|
1990
2052
|
}
|
|
1991
2053
|
});
|
|
2054
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
2055
|
+
if (!a1Cookie) return {
|
|
2056
|
+
code: 200,
|
|
2057
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
2058
|
+
data: []
|
|
2059
|
+
};
|
|
1992
2060
|
try {
|
|
2061
|
+
const xt = Date.now().toString();
|
|
2062
|
+
const topicData = {
|
|
2063
|
+
keyword: params.searchValue,
|
|
2064
|
+
suggest_topic_request: {
|
|
2065
|
+
title: "",
|
|
2066
|
+
desc: `#${params.searchValue}`
|
|
2067
|
+
},
|
|
2068
|
+
page: {
|
|
2069
|
+
page_size: 20,
|
|
2070
|
+
page: 1
|
|
2071
|
+
}
|
|
2072
|
+
};
|
|
2073
|
+
const topicDataStr = searchXiaohongshuTopicList_xsEncrypt.dumps(topicData);
|
|
2074
|
+
const fatchTopic = `/web_api/sns/v1/search/topic${topicDataStr}`;
|
|
2075
|
+
const xs = await searchXiaohongshuTopicList_xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
|
|
1993
2076
|
const result = await http.api({
|
|
1994
2077
|
method: "post",
|
|
1995
2078
|
url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
|
|
1996
|
-
data:
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
desc: `#${params.searchValue}`
|
|
2001
|
-
},
|
|
2002
|
-
page: {
|
|
2003
|
-
page_size: 20,
|
|
2004
|
-
page: 1
|
|
2005
|
-
}
|
|
2079
|
+
data: topicData,
|
|
2080
|
+
headers: {
|
|
2081
|
+
"x-s": xs,
|
|
2082
|
+
"x-t": xt
|
|
2006
2083
|
},
|
|
2007
2084
|
defaultErrorMsg: "话题搜索异常,请稍后重试。"
|
|
2008
2085
|
});
|
|
@@ -2545,6 +2622,726 @@ var __webpack_exports__ = {};
|
|
|
2545
2622
|
}, "获取粉丝数失败,请检查登陆有效性!");
|
|
2546
2623
|
}
|
|
2547
2624
|
};
|
|
2625
|
+
const TTSessionCheck = async (_task, params)=>{
|
|
2626
|
+
const http = new Http({
|
|
2627
|
+
headers: {
|
|
2628
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2629
|
+
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
2630
|
+
}
|
|
2631
|
+
});
|
|
2632
|
+
try {
|
|
2633
|
+
const res = await http.api({
|
|
2634
|
+
method: "get",
|
|
2635
|
+
url: "https://mp.toutiao.com/mp/agw/creator_center/user_info",
|
|
2636
|
+
defaultErrorMsg: `头条号登录状态失效。`
|
|
2637
|
+
});
|
|
2638
|
+
return (0, share_namespaceObject.success)(0 === res.code ? {
|
|
2639
|
+
isValidSession: true
|
|
2640
|
+
} : {
|
|
2641
|
+
isValidSession: false
|
|
2642
|
+
}, "头条账号有效性检测完成!");
|
|
2643
|
+
} catch (error) {
|
|
2644
|
+
return (0, share_namespaceObject.success)({
|
|
2645
|
+
isValidSession: false
|
|
2646
|
+
}, "头条账号有效性检测失败!");
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
const WxSessionCheck = async (_task, params)=>{
|
|
2650
|
+
const http = new Http({
|
|
2651
|
+
headers: {
|
|
2652
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
2653
|
+
}
|
|
2654
|
+
});
|
|
2655
|
+
const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
|
|
2656
|
+
try {
|
|
2657
|
+
const res = await http.api({
|
|
2658
|
+
method: "get",
|
|
2659
|
+
url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",
|
|
2660
|
+
params: {
|
|
2661
|
+
fingerprint,
|
|
2662
|
+
sub: "list",
|
|
2663
|
+
begin: 0,
|
|
2664
|
+
count: 10,
|
|
2665
|
+
query: "",
|
|
2666
|
+
type: 1011102103,
|
|
2667
|
+
show_type: "",
|
|
2668
|
+
free_publish_type: 1102103,
|
|
2669
|
+
sub_action: "list_ex",
|
|
2670
|
+
search_card: 0,
|
|
2671
|
+
token: params.token,
|
|
2672
|
+
lang: "zh_CN",
|
|
2673
|
+
f: "json",
|
|
2674
|
+
ajax: 1
|
|
2675
|
+
}
|
|
2676
|
+
});
|
|
2677
|
+
return (0, share_namespaceObject.success)(0 === res.base_resp.ret ? {
|
|
2678
|
+
isValidSession: true
|
|
2679
|
+
} : {
|
|
2680
|
+
isValidSession: false
|
|
2681
|
+
}, "微信账号有效性检测完成!");
|
|
2682
|
+
} catch (error) {
|
|
2683
|
+
return (0, share_namespaceObject.success)({
|
|
2684
|
+
isValidSession: false
|
|
2685
|
+
}, "微信账号有效性检测失败!");
|
|
2686
|
+
}
|
|
2687
|
+
};
|
|
2688
|
+
const XhsSessionCheck = async (_task, params)=>{
|
|
2689
|
+
const http = new Http({
|
|
2690
|
+
headers: {
|
|
2691
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2692
|
+
referer: "https://creator.xiaohongshu.com/new/home?source=official"
|
|
2693
|
+
}
|
|
2694
|
+
});
|
|
2695
|
+
try {
|
|
2696
|
+
const res = await http.api({
|
|
2697
|
+
method: "get",
|
|
2698
|
+
url: "https://creator.xiaohongshu.com/api/galaxy/user/info"
|
|
2699
|
+
});
|
|
2700
|
+
return (0, share_namespaceObject.success)(0 === res.result ? {
|
|
2701
|
+
isValidSession: true
|
|
2702
|
+
} : {
|
|
2703
|
+
isValidSession: false
|
|
2704
|
+
}, "小红书账号有效性检测完成!");
|
|
2705
|
+
} catch (error) {
|
|
2706
|
+
return (0, share_namespaceObject.success)({
|
|
2707
|
+
isValidSession: false
|
|
2708
|
+
}, "小红书账号有效性检测完成!");
|
|
2709
|
+
}
|
|
2710
|
+
};
|
|
2711
|
+
const BjhSessionCheck = async (_task, params)=>{
|
|
2712
|
+
const http = new Http({
|
|
2713
|
+
headers: {
|
|
2714
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2715
|
+
referer: "https://baijiahao.baidu.com/builder/rc/home"
|
|
2716
|
+
}
|
|
2717
|
+
});
|
|
2718
|
+
try {
|
|
2719
|
+
const res = await http.api({
|
|
2720
|
+
method: "get",
|
|
2721
|
+
url: "https://baijiahao.baidu.com/pcui/home/index",
|
|
2722
|
+
defaultErrorMsg: `百家号登录状态失效。`
|
|
2723
|
+
});
|
|
2724
|
+
return (0, share_namespaceObject.success)(0 === res.errno ? {
|
|
2725
|
+
isValidSession: true
|
|
2726
|
+
} : {
|
|
2727
|
+
isValidSession: false
|
|
2728
|
+
}, "百家号账号有效性检测完成!");
|
|
2729
|
+
} catch (error) {
|
|
2730
|
+
return (0, share_namespaceObject.success)({
|
|
2731
|
+
isValidSession: false
|
|
2732
|
+
}, "百家号账号有效性检测失败!");
|
|
2733
|
+
}
|
|
2734
|
+
};
|
|
2735
|
+
const types_errorResponse = (message, code = 500)=>({
|
|
2736
|
+
code,
|
|
2737
|
+
message,
|
|
2738
|
+
data: null
|
|
2739
|
+
});
|
|
2740
|
+
async function getBaijiahaoData(params) {
|
|
2741
|
+
try {
|
|
2742
|
+
const { token } = params;
|
|
2743
|
+
if (!token) return types_errorResponse("缺少token", 200);
|
|
2744
|
+
const http = new Http({
|
|
2745
|
+
headers: {
|
|
2746
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2747
|
+
token: String(token),
|
|
2748
|
+
Referer: "https://baijiahao.baidu.com/builder/rc/home"
|
|
2749
|
+
}
|
|
2750
|
+
});
|
|
2751
|
+
const yesterday = TimeFormatter.format(new Date().setDate(new Date().getDate() - 1), "yyyyMMdd");
|
|
2752
|
+
const [fansData, readData, incomeData, yesterdayData] = await Promise.all([
|
|
2753
|
+
http.api({
|
|
2754
|
+
method: "get",
|
|
2755
|
+
url: "https://baijiahao.baidu.com/pcui/home/index"
|
|
2756
|
+
}),
|
|
2757
|
+
http.api({
|
|
2758
|
+
method: "get",
|
|
2759
|
+
url: "https://baijiahao.baidu.com/author/eco/statistic/getauthorhistory"
|
|
2760
|
+
}),
|
|
2761
|
+
http.api({
|
|
2762
|
+
method: "get",
|
|
2763
|
+
url: "https://baijiahao.baidu.com/author/eco/income4/homepageincome"
|
|
2764
|
+
}),
|
|
2765
|
+
http.api({
|
|
2766
|
+
method: "get",
|
|
2767
|
+
url: "https://baijiahao.baidu.com/author/eco/statistics/appStatistic",
|
|
2768
|
+
params: {
|
|
2769
|
+
type: "all",
|
|
2770
|
+
is_yesterday: false,
|
|
2771
|
+
start_day: yesterday,
|
|
2772
|
+
end_day: yesterday,
|
|
2773
|
+
stat: 0
|
|
2774
|
+
}
|
|
2775
|
+
})
|
|
2776
|
+
]);
|
|
2777
|
+
const bjhData = {
|
|
2778
|
+
fansNum: fansData.data.coreData.fansCount,
|
|
2779
|
+
fansNumYesterday: -1 == yesterdayData.data.data.fans_increase ? null : yesterdayData.data.data.fans_increase,
|
|
2780
|
+
readNum: readData.data.total.view_count,
|
|
2781
|
+
incomeNum: incomeData.data.all_income.total_income,
|
|
2782
|
+
incomeNumYesterday: -1 == incomeData.data.all_income.yesterday_income ? null : incomeData.data.all_income.yesterday_income,
|
|
2783
|
+
recommendNumYesterday: -1 == yesterdayData.data.data.recommend_count ? null : yesterdayData.data.data.recommend_count,
|
|
2784
|
+
readNumYesterday: -1 == yesterdayData.data.data.view_count ? null : yesterdayData.data.data.view_count,
|
|
2785
|
+
likeNumYesterday: -1 == yesterdayData.data.data.likes_count ? null : yesterdayData.data.data.likes_count,
|
|
2786
|
+
commentNumYesterday: -1 == yesterdayData.data.data.comment_count ? null : yesterdayData.data.data.comment_count
|
|
2787
|
+
};
|
|
2788
|
+
return (0, share_namespaceObject.success)(bjhData, "百家号平台数据获取成功!");
|
|
2789
|
+
} catch (error) {
|
|
2790
|
+
return types_errorResponse(error instanceof Error ? error.message : "百家号平台数据获取失败");
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
async function getToutiaoData(params) {
|
|
2794
|
+
const { cookies } = params;
|
|
2795
|
+
try {
|
|
2796
|
+
const http = new Http({
|
|
2797
|
+
headers: {
|
|
2798
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2799
|
+
referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
|
|
2800
|
+
}
|
|
2801
|
+
});
|
|
2802
|
+
const [totalData, contentDataYesterday] = await Promise.all([
|
|
2803
|
+
http.api({
|
|
2804
|
+
method: "get",
|
|
2805
|
+
url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
|
|
2806
|
+
params: {
|
|
2807
|
+
app_id: 1231
|
|
2808
|
+
}
|
|
2809
|
+
}),
|
|
2810
|
+
http.api({
|
|
2811
|
+
method: "get",
|
|
2812
|
+
url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
|
|
2813
|
+
params: {
|
|
2814
|
+
type: 0,
|
|
2815
|
+
app_id: 1231
|
|
2816
|
+
}
|
|
2817
|
+
})
|
|
2818
|
+
]);
|
|
2819
|
+
const ttData = {
|
|
2820
|
+
fansNum: Number(totalData.data.statistic.data.total_subscribe_count),
|
|
2821
|
+
fansNumYesterday: void 0 !== totalData.data.statistic.data.yesterday_fans ? Number(totalData.data.statistic.data.yesterday_fans) : null,
|
|
2822
|
+
readNum: Number(totalData.data.statistic.data.total_read_play_count),
|
|
2823
|
+
incomeNum: totalData.data.statistic.data.total_income,
|
|
2824
|
+
incomeNumYesterday: totalData.data.statistic.data.is_yesterday_income_ready ? totalData.data.statistic.data.yesterday_income : null,
|
|
2825
|
+
showNumYesterday: contentDataYesterday.author_stat.consume_data.impression_count,
|
|
2826
|
+
readNumYesterday: contentDataYesterday.author_stat.consume_data.go_detail_count,
|
|
2827
|
+
likeNumYesterday: contentDataYesterday.author_stat.interaction_data.digg_count,
|
|
2828
|
+
commentNumYesterday: contentDataYesterday.author_stat.interaction_data.comment_count
|
|
2829
|
+
};
|
|
2830
|
+
return (0, share_namespaceObject.success)(ttData, "头条号粉丝数据获取成功!");
|
|
2831
|
+
} catch (error) {
|
|
2832
|
+
return types_errorResponse(error instanceof Error ? error.message : "头条号数据获取失败");
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
async function getWeixinData(params) {
|
|
2836
|
+
const { token } = params;
|
|
2837
|
+
if (!token) return {
|
|
2838
|
+
code: 200,
|
|
2839
|
+
message: "缺少token",
|
|
2840
|
+
data: null
|
|
2841
|
+
};
|
|
2842
|
+
try {
|
|
2843
|
+
const { token } = params;
|
|
2844
|
+
if (!token) return types_errorResponse("缺少token", 200);
|
|
2845
|
+
const http = new Http({
|
|
2846
|
+
headers: {
|
|
2847
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
2848
|
+
}
|
|
2849
|
+
});
|
|
2850
|
+
const userInfo = {
|
|
2851
|
+
originalCount: 0,
|
|
2852
|
+
totalUsers: 0,
|
|
2853
|
+
userIncrease: 0,
|
|
2854
|
+
yesterday: {
|
|
2855
|
+
read: 0,
|
|
2856
|
+
share: 0,
|
|
2857
|
+
subscribe: 0
|
|
2858
|
+
}
|
|
2859
|
+
};
|
|
2860
|
+
const userInfoHtml = await http.api({
|
|
2861
|
+
method: "get",
|
|
2862
|
+
url: "https://mp.weixin.qq.com/cgi-bin/home",
|
|
2863
|
+
params: {
|
|
2864
|
+
t: "home/index",
|
|
2865
|
+
token,
|
|
2866
|
+
lang: "zh_CN"
|
|
2867
|
+
}
|
|
2868
|
+
});
|
|
2869
|
+
const originalMatch = userInfoHtml.trim().match(/原创内容[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2870
|
+
if (originalMatch) userInfo.originalCount = parseInt(originalMatch[1].replace(/,/g, ''), 10);
|
|
2871
|
+
const totalUsersMatch = userInfoHtml.match(/总用户数[\s\S]*?<div[^>]*class=["']weui-desktop-user_sum["'][^>]*>[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2872
|
+
if (totalUsersMatch) userInfo.totalUsers = parseInt(totalUsersMatch[1].replace(/,/g, ''), 10);
|
|
2873
|
+
const increaseMatch = userInfoHtml.match(/weui-desktop-user_increase_num[^>]*>\s*([+-]?)\s*<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2874
|
+
if (increaseMatch) {
|
|
2875
|
+
const sign = '-' === increaseMatch[1] ? -1 : 1;
|
|
2876
|
+
userInfo.userIncrease = sign * parseInt(increaseMatch[2].replace(/,/g, ''), 10);
|
|
2877
|
+
}
|
|
2878
|
+
const readMatch = userInfoHtml.match(/昨日阅读[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2879
|
+
if (readMatch) userInfo.yesterday.read = parseInt(readMatch[1].replace(/,/g, ''), 10);
|
|
2880
|
+
const shareMatch = userInfoHtml.match(/昨日分享[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2881
|
+
if (shareMatch) userInfo.yesterday.share = parseInt(shareMatch[1].replace(/,/g, ''), 10);
|
|
2882
|
+
const subscribeMatch = userInfoHtml.match(/昨日新增关注[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
|
|
2883
|
+
if (subscribeMatch) userInfo.yesterday.subscribe = parseInt(subscribeMatch[1].replace(/,/g, ''), 10);
|
|
2884
|
+
const wxData = {
|
|
2885
|
+
fansNum: userInfo.totalUsers,
|
|
2886
|
+
fansNumYesterday: userInfo.yesterday.subscribe,
|
|
2887
|
+
readNumYesterday: userInfo.yesterday.read,
|
|
2888
|
+
shareNumYesterday: userInfo.yesterday.share
|
|
2889
|
+
};
|
|
2890
|
+
return (0, share_namespaceObject.success)(wxData, "微信平台数据获取成功!");
|
|
2891
|
+
} catch (error) {
|
|
2892
|
+
return types_errorResponse(error instanceof Error ? error.message : "微信平台数据获取失败");
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
async function getXiaohongshuData(params) {
|
|
2896
|
+
try {
|
|
2897
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
2898
|
+
if (!a1Cookie) return types_errorResponse("账号数据异常,请重新绑定账号后重试。", 200);
|
|
2899
|
+
const http = new Http({
|
|
2900
|
+
headers: {
|
|
2901
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
2902
|
+
referer: "https://creator.xiaohongshu.com",
|
|
2903
|
+
origin: "https://creator.xiaohongshu.com"
|
|
2904
|
+
}
|
|
2905
|
+
});
|
|
2906
|
+
const xsEncrypt = new XsEncrypt();
|
|
2907
|
+
const xt = Date.now().toString();
|
|
2908
|
+
const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
|
|
2909
|
+
const xs = await xsEncrypt.encryptXs(sevenDataUrl, a1Cookie, xt);
|
|
2910
|
+
const [overAllData, sevenData] = await Promise.all([
|
|
2911
|
+
http.api({
|
|
2912
|
+
method: "get",
|
|
2913
|
+
url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
|
|
2914
|
+
}),
|
|
2915
|
+
http.api({
|
|
2916
|
+
method: "get",
|
|
2917
|
+
baseURL: "https://creator.xiaohongshu.com",
|
|
2918
|
+
url: sevenDataUrl,
|
|
2919
|
+
headers: {
|
|
2920
|
+
"x-s": xs,
|
|
2921
|
+
"x-t": xt
|
|
2922
|
+
}
|
|
2923
|
+
})
|
|
2924
|
+
]);
|
|
2925
|
+
const xhsData = {
|
|
2926
|
+
fansNum: overAllData.data.fans_count,
|
|
2927
|
+
favedNum: overAllData.data.faved_count,
|
|
2928
|
+
watchNumLastWeek: sevenData.data.seven.view_count,
|
|
2929
|
+
likeNumLastWeek: sevenData.data.seven.like_count,
|
|
2930
|
+
collectNumLastWeek: sevenData.data.seven.collect_count,
|
|
2931
|
+
commentNumLastWeek: sevenData.data.seven.comment_count,
|
|
2932
|
+
fansNumLastWeek: sevenData.data.seven.rise_fans_count,
|
|
2933
|
+
fansNumYesterday: sevenData.data.seven.rise_fans_list[0].count
|
|
2934
|
+
};
|
|
2935
|
+
return (0, share_namespaceObject.success)(xhsData, "小红书平台数据获取成功!");
|
|
2936
|
+
} catch (error) {
|
|
2937
|
+
return types_errorResponse(error instanceof Error ? error.message : "小红书平台数据获取失败");
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
const SearchAccountInfo = async (_task, params)=>{
|
|
2941
|
+
const { platform } = params;
|
|
2942
|
+
switch(platform){
|
|
2943
|
+
case "toutiao":
|
|
2944
|
+
return getToutiaoData(params);
|
|
2945
|
+
case "xiaohongshu":
|
|
2946
|
+
return getXiaohongshuData(params);
|
|
2947
|
+
case "weixin":
|
|
2948
|
+
return getWeixinData(params);
|
|
2949
|
+
case "baijiahao":
|
|
2950
|
+
return getBaijiahaoData(params);
|
|
2951
|
+
default:
|
|
2952
|
+
return (0, share_namespaceObject.success)(null, "暂不支持该平台");
|
|
2953
|
+
}
|
|
2954
|
+
};
|
|
2955
|
+
const searchPublishInfo_types_errorResponse = (message, code = 500)=>({
|
|
2956
|
+
code,
|
|
2957
|
+
message,
|
|
2958
|
+
data: null
|
|
2959
|
+
});
|
|
2960
|
+
async function handleToutiaoData(params) {
|
|
2961
|
+
try {
|
|
2962
|
+
const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
|
|
2963
|
+
const http = new Http({
|
|
2964
|
+
headers: {
|
|
2965
|
+
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
2966
|
+
}
|
|
2967
|
+
});
|
|
2968
|
+
const visitedUid = await http.api({
|
|
2969
|
+
url: "https://mp.toutiao.com/mp/agw/creator_center/user_info?",
|
|
2970
|
+
method: "get",
|
|
2971
|
+
params: {
|
|
2972
|
+
app_id: 1231
|
|
2973
|
+
}
|
|
2974
|
+
});
|
|
2975
|
+
const articleInfo = await http.api({
|
|
2976
|
+
method: "get",
|
|
2977
|
+
url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
|
|
2978
|
+
params: {
|
|
2979
|
+
provider_type: "mp_provider",
|
|
2980
|
+
aid: "13",
|
|
2981
|
+
app_name: "news_article",
|
|
2982
|
+
category: "mp_all",
|
|
2983
|
+
channel: "",
|
|
2984
|
+
stream_api_version: "88",
|
|
2985
|
+
genre_type_switch: '{"repost":1,"small_video":1,"toutiao_graphic":1,"weitoutiao":1,"xigua_video":1}',
|
|
2986
|
+
device_platform: "pc",
|
|
2987
|
+
platform_id: "0",
|
|
2988
|
+
visited_uid: visitedUid.user_id_str,
|
|
2989
|
+
offset: (pageNum - 1) * pageSize,
|
|
2990
|
+
count: pageSize,
|
|
2991
|
+
keyword: "",
|
|
2992
|
+
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"}`,
|
|
2993
|
+
app_id: "1231"
|
|
2994
|
+
}
|
|
2995
|
+
});
|
|
2996
|
+
const articleCell = articleInfo.data.map((item)=>({
|
|
2997
|
+
title: item.assembleCell.itemCell.articleBase.title,
|
|
2998
|
+
imageUrl: item.assembleCell.itemCell.imageList.staggerFeedCover[0].url,
|
|
2999
|
+
createTime: item.assembleCell.itemCell.articleBase.publishTime,
|
|
3000
|
+
redirectUrl: item.assembleCell.itemCell.articleBase.articleURL,
|
|
3001
|
+
showNum: item.assembleCell.itemCell.itemCounter.showCount,
|
|
3002
|
+
readNum: item.assembleCell.itemCell.itemCounter.readCount,
|
|
3003
|
+
likeNum: item.assembleCell.itemCell.itemCounter.diggCount,
|
|
3004
|
+
commentNum: item.assembleCell.itemCell.itemCounter.commentCount,
|
|
3005
|
+
...showOriginalData ? {
|
|
3006
|
+
originalData: item
|
|
3007
|
+
} : {}
|
|
3008
|
+
}));
|
|
3009
|
+
const api_base_info_json = JSON.parse(articleInfo.api_base_info.app_extra_params);
|
|
3010
|
+
return (0, share_namespaceObject.success)({
|
|
3011
|
+
articleCell,
|
|
3012
|
+
...onlySuccess ? {
|
|
3013
|
+
pagination: {
|
|
3014
|
+
total: api_base_info_json.total_count || -1,
|
|
3015
|
+
pageNum,
|
|
3016
|
+
pageSize
|
|
3017
|
+
}
|
|
3018
|
+
} : null
|
|
3019
|
+
}, "头条号文章文章获取成功");
|
|
3020
|
+
} catch (error) {
|
|
3021
|
+
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "头条号文章数据获取失败");
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
3024
|
+
async function handleWeixinData(params) {
|
|
3025
|
+
try {
|
|
3026
|
+
const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
|
|
3027
|
+
if (!token) return {
|
|
3028
|
+
code: 200,
|
|
3029
|
+
message: "缺少token",
|
|
3030
|
+
data: null
|
|
3031
|
+
};
|
|
3032
|
+
const http = new Http({
|
|
3033
|
+
headers: {
|
|
3034
|
+
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
3035
|
+
}
|
|
3036
|
+
});
|
|
3037
|
+
const ParsePublishPage = (body)=>{
|
|
3038
|
+
const match = body.match(/publish_page\s*=\s*({[\s\S]*?});/);
|
|
3039
|
+
if (!match) throw new Error('无法提取 publish_page 字段');
|
|
3040
|
+
let parsedData = JSON.parse(match[1]);
|
|
3041
|
+
const decodeEntities = function(str, decode = false) {
|
|
3042
|
+
const encodeMap = [
|
|
3043
|
+
"&",
|
|
3044
|
+
"&",
|
|
3045
|
+
"<",
|
|
3046
|
+
"<",
|
|
3047
|
+
">",
|
|
3048
|
+
">",
|
|
3049
|
+
" ",
|
|
3050
|
+
" ",
|
|
3051
|
+
'"',
|
|
3052
|
+
""",
|
|
3053
|
+
"'",
|
|
3054
|
+
"'"
|
|
3055
|
+
];
|
|
3056
|
+
const decodeMap = [
|
|
3057
|
+
"'",
|
|
3058
|
+
"'",
|
|
3059
|
+
""",
|
|
3060
|
+
'"',
|
|
3061
|
+
" ",
|
|
3062
|
+
" ",
|
|
3063
|
+
">",
|
|
3064
|
+
">",
|
|
3065
|
+
"<",
|
|
3066
|
+
"<",
|
|
3067
|
+
"&",
|
|
3068
|
+
"&",
|
|
3069
|
+
"<",
|
|
3070
|
+
"<",
|
|
3071
|
+
">",
|
|
3072
|
+
">"
|
|
3073
|
+
];
|
|
3074
|
+
const map = decode ? decodeMap : encodeMap;
|
|
3075
|
+
let result = str;
|
|
3076
|
+
for(let i = 0; i < map.length; i += 2)result = result.replace(new RegExp(map[i], "g"), map[i + 1]);
|
|
3077
|
+
return result;
|
|
3078
|
+
};
|
|
3079
|
+
const finalData = {
|
|
3080
|
+
...parsedData,
|
|
3081
|
+
publish_list: parsedData.publish_list.map((item)=>{
|
|
3082
|
+
const decoded = decodeEntities(item.publish_info, true);
|
|
3083
|
+
const parsedInfo = JSON.parse(decoded);
|
|
3084
|
+
return {
|
|
3085
|
+
publish_type: item.publish_type,
|
|
3086
|
+
publish_info: parsedInfo
|
|
3087
|
+
};
|
|
3088
|
+
})
|
|
3089
|
+
};
|
|
3090
|
+
return finalData;
|
|
3091
|
+
};
|
|
3092
|
+
async function fetchArticles(begin, pageSize, token) {
|
|
3093
|
+
return http.api({
|
|
3094
|
+
method: "get",
|
|
3095
|
+
url: 'https://mp.weixin.qq.com/cgi-bin/appmsgpublish',
|
|
3096
|
+
params: {
|
|
3097
|
+
sub: "list",
|
|
3098
|
+
begin: begin,
|
|
3099
|
+
count: pageSize,
|
|
3100
|
+
token: token,
|
|
3101
|
+
lang: "zh_CN"
|
|
3102
|
+
}
|
|
3103
|
+
});
|
|
3104
|
+
}
|
|
3105
|
+
let size = pageSize > 20 ? 20 : pageSize;
|
|
3106
|
+
let rawArticlesInfo = await fetchArticles((pageNum - 1) * size, size, token);
|
|
3107
|
+
let articlesInfo = ParsePublishPage(rawArticlesInfo);
|
|
3108
|
+
if (!onlySuccess && pageSize > 20) {
|
|
3109
|
+
let totalFetched = articlesInfo.publish_list.length;
|
|
3110
|
+
let nextPage = pageNum + 1;
|
|
3111
|
+
while(totalFetched < pageSize){
|
|
3112
|
+
const remaining = pageSize - totalFetched;
|
|
3113
|
+
const currentPageSize = remaining > 20 ? 20 : remaining;
|
|
3114
|
+
let _rawArticlesInfo = await fetchArticles((nextPage - 1) * 20, currentPageSize, token);
|
|
3115
|
+
let parsed = ParsePublishPage(_rawArticlesInfo);
|
|
3116
|
+
articlesInfo.publish_list = articlesInfo.publish_list.concat(parsed.publish_list);
|
|
3117
|
+
totalFetched = articlesInfo.publish_list.length;
|
|
3118
|
+
if (parsed.publish_list.length < currentPageSize) break;
|
|
3119
|
+
nextPage++;
|
|
3120
|
+
}
|
|
3121
|
+
}
|
|
3122
|
+
const articleCell = articlesInfo?.publish_list.map((item)=>({
|
|
3123
|
+
title: item.publish_info.appmsg_info[0].title,
|
|
3124
|
+
imageUrl: item.publish_info.appmsg_info[0].cover,
|
|
3125
|
+
createTime: item.publish_info.appmsg_info[0].line_info.send_time,
|
|
3126
|
+
redirectUrl: item.publish_info.appmsg_info[0].content_url,
|
|
3127
|
+
readNum: item.publish_info.appmsg_info[0].read_num,
|
|
3128
|
+
likeNum: item.publish_info.appmsg_info[0].old_like_num,
|
|
3129
|
+
shareNum: item.publish_info.appmsg_info[0].share_num,
|
|
3130
|
+
recommendNum: item.publish_info.appmsg_info[0].like_num,
|
|
3131
|
+
...showOriginalData ? {
|
|
3132
|
+
originalData: item
|
|
3133
|
+
} : {}
|
|
3134
|
+
}));
|
|
3135
|
+
return (0, share_namespaceObject.success)({
|
|
3136
|
+
articleCell,
|
|
3137
|
+
...onlySuccess ? {
|
|
3138
|
+
pagination: {
|
|
3139
|
+
total: articlesInfo?.total_count,
|
|
3140
|
+
pageNum,
|
|
3141
|
+
pageSize
|
|
3142
|
+
}
|
|
3143
|
+
} : null
|
|
3144
|
+
}, "微信文章文章获取成功");
|
|
3145
|
+
} catch (error) {
|
|
3146
|
+
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "微信文章数据获取失败");
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
async function handleBaijiahaoData(params) {
|
|
3150
|
+
try {
|
|
3151
|
+
const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
|
|
3152
|
+
if (!token) return {
|
|
3153
|
+
code: 200,
|
|
3154
|
+
message: "缺少token",
|
|
3155
|
+
data: null
|
|
3156
|
+
};
|
|
3157
|
+
const http = new Http({
|
|
3158
|
+
headers: {
|
|
3159
|
+
cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
3160
|
+
token: token
|
|
3161
|
+
}
|
|
3162
|
+
});
|
|
3163
|
+
async function fetchArticles(pageNum, pageSize, onlySuccess = false) {
|
|
3164
|
+
return await http.api({
|
|
3165
|
+
method: "get",
|
|
3166
|
+
url: "https://baijiahao.baidu.com/pcui/article/lists",
|
|
3167
|
+
params: {
|
|
3168
|
+
currentPage: pageNum,
|
|
3169
|
+
pageSize: pageSize,
|
|
3170
|
+
search: "",
|
|
3171
|
+
type: "",
|
|
3172
|
+
collection: onlySuccess ? "publish" : "",
|
|
3173
|
+
clearBeforeFetch: false,
|
|
3174
|
+
dynamic: 1
|
|
3175
|
+
}
|
|
3176
|
+
});
|
|
3177
|
+
}
|
|
3178
|
+
const articleInfo = await fetchArticles(pageNum, pageSize, onlySuccess);
|
|
3179
|
+
let filtered = articleInfo.data.list.filter((item)=>"draft" !== item.status);
|
|
3180
|
+
const totalPage = articleInfo.data.page?.totalPage || 1;
|
|
3181
|
+
let currentPage = pageNum + 1;
|
|
3182
|
+
const usedPages = new Set();
|
|
3183
|
+
while(filtered.length < pageSize && currentPage <= totalPage){
|
|
3184
|
+
if (usedPages.has(currentPage)) {
|
|
3185
|
+
currentPage++;
|
|
3186
|
+
continue;
|
|
3187
|
+
}
|
|
3188
|
+
const res = await fetchArticles(currentPage, pageSize, onlySuccess);
|
|
3189
|
+
usedPages.add(currentPage);
|
|
3190
|
+
const validItems = res.data.list.filter((item)=>"draft" !== item.status);
|
|
3191
|
+
filtered.push(...validItems);
|
|
3192
|
+
currentPage++;
|
|
3193
|
+
}
|
|
3194
|
+
const final = filtered.slice(0, pageSize);
|
|
3195
|
+
const articleCell = final.map((item)=>({
|
|
3196
|
+
title: item.title,
|
|
3197
|
+
imageUrl: JSON.parse(item.cover_images)[0].src,
|
|
3198
|
+
createTime: Math.floor(new Date(item.publish_at.replace(/-/g, "/")).getTime() / 1000),
|
|
3199
|
+
redirectUrl: item.url,
|
|
3200
|
+
recommendNum: item.rec_amount,
|
|
3201
|
+
collectNum: item.collection_amount,
|
|
3202
|
+
readNum: item.read_amount,
|
|
3203
|
+
likeNum: item.like_amount,
|
|
3204
|
+
commentNum: item.comment_amount,
|
|
3205
|
+
shareNum: item.share_amount,
|
|
3206
|
+
...showOriginalData ? {
|
|
3207
|
+
originalData: item
|
|
3208
|
+
} : {}
|
|
3209
|
+
}));
|
|
3210
|
+
return (0, share_namespaceObject.success)({
|
|
3211
|
+
articleCell,
|
|
3212
|
+
...onlySuccess ? {
|
|
3213
|
+
pagination: {
|
|
3214
|
+
total: articleInfo.data.page?.totalCount,
|
|
3215
|
+
pageNum,
|
|
3216
|
+
pageSize
|
|
3217
|
+
}
|
|
3218
|
+
} : null
|
|
3219
|
+
}, "百家号文章数据获取成功");
|
|
3220
|
+
} catch (error) {
|
|
3221
|
+
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
|
|
3222
|
+
}
|
|
3223
|
+
}
|
|
3224
|
+
async function handleXiaohongshuData(params) {
|
|
3225
|
+
try {
|
|
3226
|
+
const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
|
|
3227
|
+
const xsEncrypt = new XsEncrypt();
|
|
3228
|
+
const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
|
|
3229
|
+
if (!a1Cookie) return {
|
|
3230
|
+
code: 200,
|
|
3231
|
+
message: "账号数据异常",
|
|
3232
|
+
data: null
|
|
3233
|
+
};
|
|
3234
|
+
if (onlySuccess && 10 != pageSize) return {
|
|
3235
|
+
code: 200,
|
|
3236
|
+
message: "小红书pageSize不可修改",
|
|
3237
|
+
data: null
|
|
3238
|
+
};
|
|
3239
|
+
const http = new Http({
|
|
3240
|
+
headers: {
|
|
3241
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
3242
|
+
referer: "https://creator.xiaohongshu.com",
|
|
3243
|
+
origin: "https://creator.xiaohongshu.com"
|
|
3244
|
+
}
|
|
3245
|
+
});
|
|
3246
|
+
async function fetchArticles(pageNum, a1Cookie, onlySuccess = false) {
|
|
3247
|
+
const xt = Date.now().toString();
|
|
3248
|
+
const serveUrl = `/web_api/sns/v5/creator/note/user/posted?tab=${onlySuccess ? 1 : 0}&page=${pageNum - 1}`;
|
|
3249
|
+
const xs = await xsEncrypt.encryptXs(serveUrl, a1Cookie, xt);
|
|
3250
|
+
return await http.api({
|
|
3251
|
+
method: "get",
|
|
3252
|
+
baseURL: "https://edith.xiaohongshu.com",
|
|
3253
|
+
url: serveUrl,
|
|
3254
|
+
headers: {
|
|
3255
|
+
"x-s": xs,
|
|
3256
|
+
"x-t": xt
|
|
3257
|
+
}
|
|
3258
|
+
});
|
|
3259
|
+
}
|
|
3260
|
+
const articleInfo = await fetchArticles(pageNum, a1Cookie, onlySuccess);
|
|
3261
|
+
let hasNextpage = -1 != articleInfo.data.page;
|
|
3262
|
+
let filtered = articleInfo.data.notes;
|
|
3263
|
+
let currentPage = pageNum + 1;
|
|
3264
|
+
const usedPages = new Set();
|
|
3265
|
+
while(filtered.length < pageSize && hasNextpage){
|
|
3266
|
+
if (usedPages.has(currentPage)) {
|
|
3267
|
+
currentPage++;
|
|
3268
|
+
continue;
|
|
3269
|
+
}
|
|
3270
|
+
const res = await fetchArticles(currentPage, a1Cookie, onlySuccess);
|
|
3271
|
+
usedPages.add(currentPage);
|
|
3272
|
+
const validItems = res.data.notes;
|
|
3273
|
+
filtered.push(...validItems);
|
|
3274
|
+
currentPage++;
|
|
3275
|
+
hasNextpage = -1 != res.data.page;
|
|
3276
|
+
}
|
|
3277
|
+
const final = filtered.slice(0, pageSize);
|
|
3278
|
+
const articleCell = final.map((item)=>({
|
|
3279
|
+
title: item.display_title,
|
|
3280
|
+
imageUrl: item.images_list[0].url,
|
|
3281
|
+
createTime: Math.floor(new Date(item.time.replace(/-/g, "/")).getTime() / 1000),
|
|
3282
|
+
redirectUrl: `https://www.xiaohongshu.com/explore/${item.id}?xsec_token=${item.xsec_token}&xsec_source=pc_creatormng`,
|
|
3283
|
+
readNum: item.view_count,
|
|
3284
|
+
likeNum: item.likes,
|
|
3285
|
+
commentNum: item.comments_count,
|
|
3286
|
+
collectNum: item.collected_count,
|
|
3287
|
+
shareNum: item.shared_count,
|
|
3288
|
+
...showOriginalData ? {
|
|
3289
|
+
originalData: item
|
|
3290
|
+
} : {}
|
|
3291
|
+
}));
|
|
3292
|
+
return (0, share_namespaceObject.success)({
|
|
3293
|
+
articleCell,
|
|
3294
|
+
...onlySuccess ? {
|
|
3295
|
+
pagination: {
|
|
3296
|
+
nextPage: hasNextpage,
|
|
3297
|
+
pageNum,
|
|
3298
|
+
pageSize
|
|
3299
|
+
}
|
|
3300
|
+
} : null
|
|
3301
|
+
}, "小红书文章数据获取成功");
|
|
3302
|
+
} catch (error) {
|
|
3303
|
+
return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "小红书文章数据获取失败");
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
const FetchArticles = async (_task, params)=>{
|
|
3307
|
+
const { platform } = params;
|
|
3308
|
+
switch(platform){
|
|
3309
|
+
case "toutiao":
|
|
3310
|
+
return handleToutiaoData(params);
|
|
3311
|
+
case "weixin":
|
|
3312
|
+
return handleWeixinData(params);
|
|
3313
|
+
case "baijiahao":
|
|
3314
|
+
return handleBaijiahaoData(params);
|
|
3315
|
+
case "xiaohongshu":
|
|
3316
|
+
return handleXiaohongshuData(params);
|
|
3317
|
+
default:
|
|
3318
|
+
return (0, share_namespaceObject.success)(null, "暂不支持该平台");
|
|
3319
|
+
}
|
|
3320
|
+
};
|
|
3321
|
+
const getWeixinConfig = async (_task, params)=>{
|
|
3322
|
+
const http = new Http({
|
|
3323
|
+
headers: {
|
|
3324
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
|
|
3325
|
+
}
|
|
3326
|
+
});
|
|
3327
|
+
const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
|
|
3328
|
+
const res = await http.api({
|
|
3329
|
+
method: "get",
|
|
3330
|
+
url: "https://mp.weixin.qq.com/cgi-bin/masssendpage",
|
|
3331
|
+
params: {
|
|
3332
|
+
f: 'json',
|
|
3333
|
+
token: params.token,
|
|
3334
|
+
lang: 'zh_CN',
|
|
3335
|
+
ajax: 1,
|
|
3336
|
+
fingerprint: fingerprint,
|
|
3337
|
+
random: Math.random().toString()
|
|
3338
|
+
}
|
|
3339
|
+
});
|
|
3340
|
+
const filtered = {
|
|
3341
|
+
publishQuota: 0 === res.base_resp.ret ? res.quota_detail_list.filter((item)=>"kQuotaTypeMassSendNormal" === item.quota_type).map((item)=>item.quota_item_list) : []
|
|
3342
|
+
};
|
|
3343
|
+
return (0, share_namespaceObject.success)(filtered, 0 === res.base_resp.ret ? "微信配置信息获取成功!" : "微信配置信息获取失败!");
|
|
3344
|
+
};
|
|
2548
3345
|
const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
|
|
2549
3346
|
const tmpCachePath = task.getTmpPath();
|
|
2550
3347
|
const http = new Http({
|
|
@@ -4066,66 +4863,14 @@ var __webpack_exports__ = {};
|
|
|
4066
4863
|
if ("mockApi" === params.actionType) return weixinmpPublish_mock_mockAction(task, params);
|
|
4067
4864
|
return executeAction(weixinmpPublish_mock_mockAction, weixinmpPublish_rpa_rpaAction)(task, params);
|
|
4068
4865
|
};
|
|
4069
|
-
const external_node_buffer_namespaceObject = require("node:buffer");
|
|
4070
|
-
const external_node_crypto_namespaceObject = require("node:crypto");
|
|
4071
|
-
var external_node_crypto_default = /*#__PURE__*/ __webpack_require__.n(external_node_crypto_namespaceObject);
|
|
4072
|
-
class XsEncrypt {
|
|
4073
|
-
async encryptMD5(url) {
|
|
4074
|
-
return external_node_crypto_default().createHash("md5").update(url, "utf8").digest("hex");
|
|
4075
|
-
}
|
|
4076
|
-
async encryptText(text) {
|
|
4077
|
-
const textEncoded = external_node_buffer_namespaceObject.Buffer.from(text).toString("base64");
|
|
4078
|
-
const cipher = external_node_crypto_default().createCipheriv("aes-128-cbc", new Uint8Array(this.keyBytes), new Uint8Array(this.iv));
|
|
4079
|
-
const ciphertext = cipher.update(textEncoded, "utf8", "base64");
|
|
4080
|
-
return ciphertext + cipher.final("base64");
|
|
4081
|
-
}
|
|
4082
|
-
async base64ToHex(encodedData) {
|
|
4083
|
-
const decodedData = external_node_buffer_namespaceObject.Buffer.from(encodedData, "base64");
|
|
4084
|
-
return decodedData.toString("hex");
|
|
4085
|
-
}
|
|
4086
|
-
async encryptPayload(payload, platform) {
|
|
4087
|
-
const hexPayload = await this.base64ToHex(payload);
|
|
4088
|
-
const obj = {
|
|
4089
|
-
signSvn: "56",
|
|
4090
|
-
signType: "x2",
|
|
4091
|
-
appID: platform,
|
|
4092
|
-
signVersion: "1",
|
|
4093
|
-
payload: hexPayload
|
|
4094
|
-
};
|
|
4095
|
-
const jsonString = JSON.stringify(obj, null, 0);
|
|
4096
|
-
return external_node_buffer_namespaceObject.Buffer.from(jsonString).toString("base64");
|
|
4097
|
-
}
|
|
4098
|
-
async encryptXs(url, a1, ts, platform = "xhs-pc-web") {
|
|
4099
|
-
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};`;
|
|
4100
|
-
return `XYW_${await this.encryptPayload(await this.encryptText(text), platform)}`;
|
|
4101
|
-
}
|
|
4102
|
-
dumps(...rest) {
|
|
4103
|
-
const [data, replacer = null, space = 0] = rest;
|
|
4104
|
-
return JSON.stringify(data, replacer, space).replace(/\n/g, "").replace(/":\s+"/g, '":"');
|
|
4105
|
-
}
|
|
4106
|
-
constructor(){
|
|
4107
|
-
this.words = [
|
|
4108
|
-
929260340,
|
|
4109
|
-
1633971297,
|
|
4110
|
-
895580464,
|
|
4111
|
-
925905270
|
|
4112
|
-
];
|
|
4113
|
-
this.keyBytes = external_node_buffer_namespaceObject.Buffer.concat(this.words.map((word)=>new Uint8Array(external_node_buffer_namespaceObject.Buffer.from([
|
|
4114
|
-
word >> 24 & 0xff,
|
|
4115
|
-
word >> 16 & 0xff,
|
|
4116
|
-
word >> 8 & 0xff,
|
|
4117
|
-
0xff & word
|
|
4118
|
-
]))));
|
|
4119
|
-
this.iv = external_node_buffer_namespaceObject.Buffer.from("4uzjr7mbsibcaldp", "utf8");
|
|
4120
|
-
}
|
|
4121
|
-
}
|
|
4122
4866
|
const xiaohongshuPublish_mock_errnoMap = {
|
|
4123
4867
|
915: "所属C端账号手机号被修改,请重新登录",
|
|
4124
4868
|
914: "所属C端账号密码被修改,请重新登录",
|
|
4125
4869
|
903: "账户已登出,需重新登陆重试!",
|
|
4126
|
-
902: "登录已过期,请重新登录!"
|
|
4870
|
+
902: "登录已过期,请重新登录!",
|
|
4871
|
+
906: "账号存在风险,请重新登录"
|
|
4127
4872
|
};
|
|
4128
|
-
const
|
|
4873
|
+
const mock_xsEncrypt = new XsEncrypt();
|
|
4129
4874
|
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
4130
4875
|
const tmpCachePath = task.getTmpPath();
|
|
4131
4876
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
@@ -4155,7 +4900,7 @@ var __webpack_exports__ = {};
|
|
|
4155
4900
|
});
|
|
4156
4901
|
const fetchCoverUrl = `/api/media/v1/upload/creator/permit?biz_name=spectrum&scene=image&file_count=${params.banners.length}&version=1&source=web`;
|
|
4157
4902
|
const xt = Date.now().toString();
|
|
4158
|
-
const xs = await
|
|
4903
|
+
const xs = await mock_xsEncrypt.encryptXs(fetchCoverUrl, a1Cookie, xt);
|
|
4159
4904
|
const coverIdInfo = await http.api({
|
|
4160
4905
|
method: "get",
|
|
4161
4906
|
baseURL: "https://creator.xiaohongshu.com",
|
|
@@ -4166,41 +4911,71 @@ var __webpack_exports__ = {};
|
|
|
4166
4911
|
"x-t": xt
|
|
4167
4912
|
}
|
|
4168
4913
|
});
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4914
|
+
let uploadInfos = [];
|
|
4915
|
+
coverIdInfo.data.uploadTempPermits.map((item)=>{
|
|
4916
|
+
uploadInfos.push({
|
|
4917
|
+
bucket: "",
|
|
4918
|
+
uploadAddr: item.uploadAddr,
|
|
4919
|
+
fileIds: item.fileIds,
|
|
4920
|
+
token: item.token
|
|
4921
|
+
});
|
|
4922
|
+
});
|
|
4923
|
+
if (0 === uploadInfos.length) return {
|
|
4172
4924
|
code: 200,
|
|
4173
4925
|
message: "图片上传失败,请稍后重试!",
|
|
4174
4926
|
data: ""
|
|
4175
4927
|
};
|
|
4176
|
-
const uploadFile = async (url, index)=>{
|
|
4928
|
+
const uploadFile = async (url, index, infoIndex = 0)=>{
|
|
4177
4929
|
const fileName = (0, share_namespaceObject.getFilenameFromUrl)(url);
|
|
4178
4930
|
const localUrl = await (0, share_namespaceObject.downloadImage)(url, external_node_path_default().join(tmpCachePath, fileName));
|
|
4179
|
-
const ossFileId = coverIds[index];
|
|
4180
4931
|
const fileBuffer = external_node_fs_default().readFileSync(localUrl);
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4932
|
+
const tryUpload = async (uploadIndex)=>{
|
|
4933
|
+
if (uploadIndex >= uploadInfos.length) {
|
|
4934
|
+
external_node_fs_default().unlinkSync(localUrl);
|
|
4935
|
+
return {
|
|
4936
|
+
ossFileId: "",
|
|
4937
|
+
ossToken: ""
|
|
4938
|
+
};
|
|
4939
|
+
}
|
|
4940
|
+
const currentInfo = uploadInfos[uploadIndex];
|
|
4941
|
+
const ossFileId = currentInfo.fileIds[0];
|
|
4942
|
+
const ossToken = currentInfo.token;
|
|
4943
|
+
const ossDomain = currentInfo.uploadAddr;
|
|
4944
|
+
try {
|
|
4945
|
+
await http.api({
|
|
4946
|
+
method: "put",
|
|
4947
|
+
url: `https://${ossDomain}/${ossFileId}`,
|
|
4948
|
+
data: fileBuffer,
|
|
4949
|
+
headers: {
|
|
4950
|
+
"x-cos-security-token": ossToken
|
|
4951
|
+
},
|
|
4952
|
+
defaultErrorMsg: "图片上传异常,请稍后重试发布。"
|
|
4953
|
+
});
|
|
4954
|
+
return {
|
|
4955
|
+
ossFileId,
|
|
4956
|
+
ossToken
|
|
4957
|
+
};
|
|
4958
|
+
} catch (error) {
|
|
4959
|
+
return tryUpload(uploadIndex + 1);
|
|
4960
|
+
}
|
|
4193
4961
|
};
|
|
4962
|
+
return tryUpload(infoIndex);
|
|
4194
4963
|
};
|
|
4195
4964
|
const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
|
|
4965
|
+
const invalidUpload = coverInfos.find((it)=>"" === it.ossToken || "" == it.ossFileId);
|
|
4966
|
+
if (invalidUpload) return {
|
|
4967
|
+
code: 200,
|
|
4968
|
+
message: "图片上传异常,请稍后重试发布。",
|
|
4969
|
+
data: ""
|
|
4970
|
+
};
|
|
4196
4971
|
if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
|
|
4197
4972
|
if (!topic["id"]) {
|
|
4198
4973
|
const topicData = {
|
|
4199
4974
|
topic_names: topic["name"]
|
|
4200
4975
|
};
|
|
4201
|
-
const topicDataStr =
|
|
4976
|
+
const topicDataStr = mock_xsEncrypt.dumps(topicData);
|
|
4202
4977
|
const publishXt = Date.now().toString();
|
|
4203
|
-
const publishXs = await
|
|
4978
|
+
const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/capa/postgw/topic/batch_customized${topicDataStr}`, a1Cookie, publishXt);
|
|
4204
4979
|
let createTopic = await http.api({
|
|
4205
4980
|
method: "POST",
|
|
4206
4981
|
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
@@ -4299,9 +5074,9 @@ var __webpack_exports__ = {};
|
|
|
4299
5074
|
} : {}
|
|
4300
5075
|
};
|
|
4301
5076
|
publishData.common.business_binds = JSON.stringify(business_binds);
|
|
4302
|
-
const publishDataStr =
|
|
5077
|
+
const publishDataStr = mock_xsEncrypt.dumps(publishData);
|
|
4303
5078
|
const publishXt = Date.now().toString();
|
|
4304
|
-
const publishXs = await
|
|
5079
|
+
const publishXs = await mock_xsEncrypt.encryptXs(`/web_api/sns/v2/note${publishDataStr}`, a1Cookie, publishXt);
|
|
4305
5080
|
const publishResult = await http.api({
|
|
4306
5081
|
method: "post",
|
|
4307
5082
|
url: "https://edith.xiaohongshu.com/web_api/sns/v2/note",
|
|
@@ -4530,7 +5305,7 @@ var __webpack_exports__ = {};
|
|
|
4530
5305
|
return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
|
|
4531
5306
|
};
|
|
4532
5307
|
var package_namespaceObject = {
|
|
4533
|
-
i8: "1.2.
|
|
5308
|
+
i8: "1.2.15"
|
|
4534
5309
|
};
|
|
4535
5310
|
class Action {
|
|
4536
5311
|
constructor(task){
|
|
@@ -4552,6 +5327,24 @@ var __webpack_exports__ = {};
|
|
|
4552
5327
|
} else this.task.logger.info(`${func.name} action success`);
|
|
4553
5328
|
return responseData;
|
|
4554
5329
|
}
|
|
5330
|
+
FetchArticles(params) {
|
|
5331
|
+
return this.bindTask(FetchArticles, params);
|
|
5332
|
+
}
|
|
5333
|
+
SearchAccountInfo(params) {
|
|
5334
|
+
return this.bindTask(SearchAccountInfo, params);
|
|
5335
|
+
}
|
|
5336
|
+
TTSessionCheck(params) {
|
|
5337
|
+
return this.bindTask(TTSessionCheck, params);
|
|
5338
|
+
}
|
|
5339
|
+
WxSessionCheck(params) {
|
|
5340
|
+
return this.bindTask(WxSessionCheck, params);
|
|
5341
|
+
}
|
|
5342
|
+
XhsSessionCheck(params) {
|
|
5343
|
+
return this.bindTask(XhsSessionCheck, params);
|
|
5344
|
+
}
|
|
5345
|
+
BjhSessionCheck(params) {
|
|
5346
|
+
return this.bindTask(BjhSessionCheck, params);
|
|
5347
|
+
}
|
|
4555
5348
|
searchToutiaoTopicList(params) {
|
|
4556
5349
|
return this.bindTask(searchToutiaoTopicList, params);
|
|
4557
5350
|
}
|
|
@@ -4576,6 +5369,9 @@ var __webpack_exports__ = {};
|
|
|
4576
5369
|
getToutiaoConfig(params) {
|
|
4577
5370
|
return this.bindTask(getToutiaoConfig, params);
|
|
4578
5371
|
}
|
|
5372
|
+
getWeixinConfig(params) {
|
|
5373
|
+
return this.bindTask(getWeixinConfig, params);
|
|
5374
|
+
}
|
|
4579
5375
|
getBaijiahaoConfig(params) {
|
|
4580
5376
|
return this.bindTask(getBaijiahaoConfig, params);
|
|
4581
5377
|
}
|