@iflyrpa/actions 1.2.15 → 1.2.16-beta.1

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
@@ -1123,7 +1123,14 @@ class Http {
1123
1123
  };
1124
1124
  }
1125
1125
  constructor(config){
1126
- this.apiClient = __WEBPACK_EXTERNAL_MODULE_axios__["default"].create(config);
1126
+ this.apiClient = __WEBPACK_EXTERNAL_MODULE_axios__["default"].create({
1127
+ ...config,
1128
+ proxy: {
1129
+ host: "localhost",
1130
+ port: 9000,
1131
+ protocol: "http"
1132
+ }
1133
+ });
1127
1134
  }
1128
1135
  addResponseInterceptor(findError) {
1129
1136
  this.apiClient.interceptors.response.use((response)=>{
@@ -1811,12 +1818,20 @@ const getBaijiahaoConfig = async (_task, params)=>{
1811
1818
  type: "news"
1812
1819
  }
1813
1820
  });
1814
- return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(res?.data?.article.activity_list.map((_item)=>({
1821
+ const data = res?.data?.article.activity_list.map((_item)=>({
1815
1822
  id: _item.id,
1816
1823
  name: _item.name,
1817
1824
  detail: _item.detail,
1818
1825
  is_enable: _item.is_enable
1819
- })) ?? [], "获取头条发布配置项成功");
1826
+ })) ?? [];
1827
+ data.push({
1828
+ id: "bjh_publish_num_left",
1829
+ name: "账号剩余发文数",
1830
+ detail: "",
1831
+ is_enable: 1,
1832
+ publish_num_left: res.data.ability.publish_num_left
1833
+ });
1834
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(data, "获取百家号配置项成功!");
1820
1835
  };
1821
1836
  const searchToutiaoTopicList = async (_task, params)=>{
1822
1837
  const http = new Http({
@@ -1983,7 +1998,7 @@ class XsEncrypt {
1983
1998
  this.iv = __WEBPACK_EXTERNAL_MODULE_node_buffer_fb286294__.Buffer.from("4uzjr7mbsibcaldp", "utf8");
1984
1999
  }
1985
2000
  }
1986
- const xsEncrypt = new XsEncrypt();
2001
+ const searchXiaohongshuTopicList_xsEncrypt = new XsEncrypt();
1987
2002
  const searchXiaohongshuTopicList = async (_task, params)=>{
1988
2003
  const http = new Http({
1989
2004
  headers: {
@@ -2011,9 +2026,9 @@ const searchXiaohongshuTopicList = async (_task, params)=>{
2011
2026
  page: 1
2012
2027
  }
2013
2028
  };
2014
- const topicDataStr = xsEncrypt.dumps(topicData);
2029
+ const topicDataStr = searchXiaohongshuTopicList_xsEncrypt.dumps(topicData);
2015
2030
  const fatchTopic = `/web_api/sns/v1/search/topic${topicDataStr}`;
2016
- const xs = await xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
2031
+ const xs = await searchXiaohongshuTopicList_xsEncrypt.encryptXs(fatchTopic, a1Cookie, xt);
2017
2032
  const result = await http.api({
2018
2033
  method: "post",
2019
2034
  url: "https://edith.xiaohongshu.com/web_api/sns/v1/search/topic",
@@ -2563,6 +2578,726 @@ const BjhFansExport = async (_task, params)=>{
2563
2578
  }, "获取粉丝数失败,请检查登陆有效性!");
2564
2579
  }
2565
2580
  };
2581
+ const TTSessionCheck = async (_task, params)=>{
2582
+ const http = new Http({
2583
+ headers: {
2584
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2585
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
2586
+ }
2587
+ });
2588
+ try {
2589
+ const res = await http.api({
2590
+ method: "get",
2591
+ url: "https://mp.toutiao.com/mp/agw/creator_center/user_info",
2592
+ defaultErrorMsg: `头条号登录状态失效。`
2593
+ });
2594
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.code ? {
2595
+ isValidSession: true
2596
+ } : {
2597
+ isValidSession: false
2598
+ }, "头条账号有效性检测完成!");
2599
+ } catch (error) {
2600
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
2601
+ isValidSession: false
2602
+ }, "头条账号有效性检测失败!");
2603
+ }
2604
+ };
2605
+ const WxSessionCheck = async (_task, params)=>{
2606
+ const http = new Http({
2607
+ headers: {
2608
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2609
+ }
2610
+ });
2611
+ const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
2612
+ try {
2613
+ const res = await http.api({
2614
+ method: "get",
2615
+ url: "https://mp.weixin.qq.com/cgi-bin/appmsgpublish",
2616
+ params: {
2617
+ fingerprint,
2618
+ sub: "list",
2619
+ begin: 0,
2620
+ count: 10,
2621
+ query: "",
2622
+ type: 1011102103,
2623
+ show_type: "",
2624
+ free_publish_type: 1102103,
2625
+ sub_action: "list_ex",
2626
+ search_card: 0,
2627
+ token: params.token,
2628
+ lang: "zh_CN",
2629
+ f: "json",
2630
+ ajax: 1
2631
+ }
2632
+ });
2633
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.base_resp.ret ? {
2634
+ isValidSession: true
2635
+ } : {
2636
+ isValidSession: false
2637
+ }, "微信账号有效性检测完成!");
2638
+ } catch (error) {
2639
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
2640
+ isValidSession: false
2641
+ }, "微信账号有效性检测失败!");
2642
+ }
2643
+ };
2644
+ const XhsSessionCheck = async (_task, params)=>{
2645
+ const http = new Http({
2646
+ headers: {
2647
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2648
+ referer: "https://creator.xiaohongshu.com/new/home?source=official"
2649
+ }
2650
+ });
2651
+ try {
2652
+ const res = await http.api({
2653
+ method: "get",
2654
+ url: "https://creator.xiaohongshu.com/api/galaxy/user/info"
2655
+ });
2656
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.result ? {
2657
+ isValidSession: true
2658
+ } : {
2659
+ isValidSession: false
2660
+ }, "小红书账号有效性检测完成!");
2661
+ } catch (error) {
2662
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
2663
+ isValidSession: false
2664
+ }, "小红书账号有效性检测完成!");
2665
+ }
2666
+ };
2667
+ const BjhSessionCheck = async (_task, params)=>{
2668
+ const http = new Http({
2669
+ headers: {
2670
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2671
+ referer: "https://baijiahao.baidu.com/builder/rc/home"
2672
+ }
2673
+ });
2674
+ try {
2675
+ const res = await http.api({
2676
+ method: "get",
2677
+ url: "https://baijiahao.baidu.com/pcui/home/index",
2678
+ defaultErrorMsg: `百家号登录状态失效。`
2679
+ });
2680
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(0 === res.errno ? {
2681
+ isValidSession: true
2682
+ } : {
2683
+ isValidSession: false
2684
+ }, "百家号账号有效性检测完成!");
2685
+ } catch (error) {
2686
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
2687
+ isValidSession: false
2688
+ }, "百家号账号有效性检测失败!");
2689
+ }
2690
+ };
2691
+ const types_errorResponse = (message, code = 500)=>({
2692
+ code,
2693
+ message,
2694
+ data: null
2695
+ });
2696
+ async function getBaijiahaoData(params) {
2697
+ try {
2698
+ const { token } = params;
2699
+ if (!token) return types_errorResponse("缺少token", 200);
2700
+ const http = new Http({
2701
+ headers: {
2702
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2703
+ token: String(token),
2704
+ Referer: "https://baijiahao.baidu.com/builder/rc/home"
2705
+ }
2706
+ });
2707
+ const yesterday = TimeFormatter.format(new Date().setDate(new Date().getDate() - 1), "yyyyMMdd");
2708
+ const [fansData, readData, incomeData, yesterdayData] = await Promise.all([
2709
+ http.api({
2710
+ method: "get",
2711
+ url: "https://baijiahao.baidu.com/pcui/home/index"
2712
+ }),
2713
+ http.api({
2714
+ method: "get",
2715
+ url: "https://baijiahao.baidu.com/author/eco/statistic/getauthorhistory"
2716
+ }),
2717
+ http.api({
2718
+ method: "get",
2719
+ url: "https://baijiahao.baidu.com/author/eco/income4/homepageincome"
2720
+ }),
2721
+ http.api({
2722
+ method: "get",
2723
+ url: "https://baijiahao.baidu.com/author/eco/statistics/appStatistic",
2724
+ params: {
2725
+ type: "all",
2726
+ is_yesterday: false,
2727
+ start_day: yesterday,
2728
+ end_day: yesterday,
2729
+ stat: 0
2730
+ }
2731
+ })
2732
+ ]);
2733
+ const bjhData = {
2734
+ fansNum: fansData.data.coreData.fansCount,
2735
+ fansNumYesterday: -1 == yesterdayData.data.data.fans_increase ? null : yesterdayData.data.data.fans_increase,
2736
+ readNum: readData.data.total.view_count,
2737
+ incomeNum: incomeData.data.all_income.total_income,
2738
+ incomeNumYesterday: -1 == incomeData.data.all_income.yesterday_income ? null : incomeData.data.all_income.yesterday_income,
2739
+ recommendNumYesterday: -1 == yesterdayData.data.data.recommend_count ? null : yesterdayData.data.data.recommend_count,
2740
+ readNumYesterday: -1 == yesterdayData.data.data.view_count ? null : yesterdayData.data.data.view_count,
2741
+ likeNumYesterday: -1 == yesterdayData.data.data.likes_count ? null : yesterdayData.data.data.likes_count,
2742
+ commentNumYesterday: -1 == yesterdayData.data.data.comment_count ? null : yesterdayData.data.data.comment_count
2743
+ };
2744
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(bjhData, "百家号平台数据获取成功!");
2745
+ } catch (error) {
2746
+ return types_errorResponse(error instanceof Error ? error.message : "百家号平台数据获取失败");
2747
+ }
2748
+ }
2749
+ async function getToutiaoData(params) {
2750
+ const { cookies } = params;
2751
+ try {
2752
+ const http = new Http({
2753
+ headers: {
2754
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2755
+ referer: "https://mp.toutiao.com/profile_v4/graphic/publish"
2756
+ }
2757
+ });
2758
+ const [totalData, contentDataYesterday] = await Promise.all([
2759
+ http.api({
2760
+ method: "get",
2761
+ url: "https://mp.toutiao.com/mp/fe_api/home/merge_v2",
2762
+ params: {
2763
+ app_id: 1231
2764
+ }
2765
+ }),
2766
+ http.api({
2767
+ method: "get",
2768
+ url: "https://mp.toutiao.com/mp/agw/statistic/v2/content_stat",
2769
+ params: {
2770
+ type: 0,
2771
+ app_id: 1231
2772
+ }
2773
+ })
2774
+ ]);
2775
+ const ttData = {
2776
+ fansNum: Number(totalData.data.statistic.data.total_subscribe_count),
2777
+ fansNumYesterday: void 0 !== totalData.data.statistic.data.yesterday_fans ? Number(totalData.data.statistic.data.yesterday_fans) : null,
2778
+ readNum: Number(totalData.data.statistic.data.total_read_play_count),
2779
+ incomeNum: totalData.data.statistic.data.total_income,
2780
+ incomeNumYesterday: totalData.data.statistic.data.is_yesterday_income_ready ? totalData.data.statistic.data.yesterday_income : null,
2781
+ showNumYesterday: contentDataYesterday.author_stat.consume_data.impression_count,
2782
+ readNumYesterday: contentDataYesterday.author_stat.consume_data.go_detail_count,
2783
+ likeNumYesterday: contentDataYesterday.author_stat.interaction_data.digg_count,
2784
+ commentNumYesterday: contentDataYesterday.author_stat.interaction_data.comment_count
2785
+ };
2786
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(ttData, "头条号粉丝数据获取成功!");
2787
+ } catch (error) {
2788
+ return types_errorResponse(error instanceof Error ? error.message : "头条号数据获取失败");
2789
+ }
2790
+ }
2791
+ async function getWeixinData(params) {
2792
+ const { token } = params;
2793
+ if (!token) return {
2794
+ code: 200,
2795
+ message: "缺少token",
2796
+ data: null
2797
+ };
2798
+ try {
2799
+ const { token } = params;
2800
+ if (!token) return types_errorResponse("缺少token", 200);
2801
+ const http = new Http({
2802
+ headers: {
2803
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2804
+ }
2805
+ });
2806
+ const userInfo = {
2807
+ originalCount: 0,
2808
+ totalUsers: 0,
2809
+ userIncrease: 0,
2810
+ yesterday: {
2811
+ read: 0,
2812
+ share: 0,
2813
+ subscribe: 0
2814
+ }
2815
+ };
2816
+ const userInfoHtml = await http.api({
2817
+ method: "get",
2818
+ url: "https://mp.weixin.qq.com/cgi-bin/home",
2819
+ params: {
2820
+ t: "home/index",
2821
+ token,
2822
+ lang: "zh_CN"
2823
+ }
2824
+ });
2825
+ const originalMatch = userInfoHtml.trim().match(/原创内容[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2826
+ if (originalMatch) userInfo.originalCount = parseInt(originalMatch[1].replace(/,/g, ''), 10);
2827
+ const totalUsersMatch = userInfoHtml.match(/总用户数[\s\S]*?<div[^>]*class=["']weui-desktop-user_sum["'][^>]*>[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2828
+ if (totalUsersMatch) userInfo.totalUsers = parseInt(totalUsersMatch[1].replace(/,/g, ''), 10);
2829
+ const increaseMatch = userInfoHtml.match(/weui-desktop-user_increase_num[^>]*>\s*([+-]?)\s*<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2830
+ if (increaseMatch) {
2831
+ const sign = '-' === increaseMatch[1] ? -1 : 1;
2832
+ userInfo.userIncrease = sign * parseInt(increaseMatch[2].replace(/,/g, ''), 10);
2833
+ }
2834
+ const readMatch = userInfoHtml.match(/昨日阅读[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2835
+ if (readMatch) userInfo.yesterday.read = parseInt(readMatch[1].replace(/,/g, ''), 10);
2836
+ const shareMatch = userInfoHtml.match(/昨日分享[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2837
+ if (shareMatch) userInfo.yesterday.share = parseInt(shareMatch[1].replace(/,/g, ''), 10);
2838
+ const subscribeMatch = userInfoHtml.match(/昨日新增关注[\s\S]*?<mp-thousandth[^>]*>([\d,]+)<\/mp-thousandth>/i);
2839
+ if (subscribeMatch) userInfo.yesterday.subscribe = parseInt(subscribeMatch[1].replace(/,/g, ''), 10);
2840
+ const wxData = {
2841
+ fansNum: userInfo.totalUsers,
2842
+ fansNumYesterday: userInfo.yesterday.subscribe,
2843
+ readNumYesterday: userInfo.yesterday.read,
2844
+ shareNumYesterday: userInfo.yesterday.share
2845
+ };
2846
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(wxData, "微信平台数据获取成功!");
2847
+ } catch (error) {
2848
+ return types_errorResponse(error instanceof Error ? error.message : "微信平台数据获取失败");
2849
+ }
2850
+ }
2851
+ async function getXiaohongshuData(params) {
2852
+ try {
2853
+ const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
2854
+ if (!a1Cookie) return types_errorResponse("账号数据异常,请重新绑定账号后重试。", 200);
2855
+ const http = new Http({
2856
+ headers: {
2857
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
2858
+ referer: "https://creator.xiaohongshu.com",
2859
+ origin: "https://creator.xiaohongshu.com"
2860
+ }
2861
+ });
2862
+ const xsEncrypt = new XsEncrypt();
2863
+ const xt = Date.now().toString();
2864
+ const sevenDataUrl = "/api/galaxy/v2/creator/datacenter/account/base";
2865
+ const xs = await xsEncrypt.encryptXs(sevenDataUrl, a1Cookie, xt);
2866
+ const [overAllData, sevenData] = await Promise.all([
2867
+ http.api({
2868
+ method: "get",
2869
+ url: "https://creator.xiaohongshu.com/api/galaxy/creator/home/personal_info"
2870
+ }),
2871
+ http.api({
2872
+ method: "get",
2873
+ baseURL: "https://creator.xiaohongshu.com",
2874
+ url: sevenDataUrl,
2875
+ headers: {
2876
+ "x-s": xs,
2877
+ "x-t": xt
2878
+ }
2879
+ })
2880
+ ]);
2881
+ const xhsData = {
2882
+ fansNum: overAllData.data.fans_count,
2883
+ favedNum: overAllData.data.faved_count,
2884
+ watchNumLastWeek: sevenData.data.seven.view_count,
2885
+ likeNumLastWeek: sevenData.data.seven.like_count,
2886
+ collectNumLastWeek: sevenData.data.seven.collect_count,
2887
+ commentNumLastWeek: sevenData.data.seven.comment_count,
2888
+ fansNumLastWeek: sevenData.data.seven.rise_fans_count,
2889
+ fansNumYesterday: sevenData.data.seven.rise_fans_list[0].count
2890
+ };
2891
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(xhsData, "小红书平台数据获取成功!");
2892
+ } catch (error) {
2893
+ return types_errorResponse(error instanceof Error ? error.message : "小红书平台数据获取失败");
2894
+ }
2895
+ }
2896
+ const SearchAccountInfo = async (_task, params)=>{
2897
+ const { platform } = params;
2898
+ switch(platform){
2899
+ case "toutiao":
2900
+ return getToutiaoData(params);
2901
+ case "xiaohongshu":
2902
+ return getXiaohongshuData(params);
2903
+ case "weixin":
2904
+ return getWeixinData(params);
2905
+ case "baijiahao":
2906
+ return getBaijiahaoData(params);
2907
+ default:
2908
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(null, "暂不支持该平台");
2909
+ }
2910
+ };
2911
+ const searchPublishInfo_types_errorResponse = (message, code = 500)=>({
2912
+ code,
2913
+ message,
2914
+ data: null
2915
+ });
2916
+ async function handleToutiaoData(params) {
2917
+ try {
2918
+ const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
2919
+ const http = new Http({
2920
+ headers: {
2921
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2922
+ }
2923
+ });
2924
+ const visitedUid = await http.api({
2925
+ url: "https://mp.toutiao.com/mp/agw/creator_center/user_info?",
2926
+ method: "get",
2927
+ params: {
2928
+ app_id: 1231
2929
+ }
2930
+ });
2931
+ const articleInfo = await http.api({
2932
+ method: "get",
2933
+ url: "https://mp.toutiao.com/api/feed/mp_provider/v1/",
2934
+ params: {
2935
+ provider_type: "mp_provider",
2936
+ aid: "13",
2937
+ app_name: "news_article",
2938
+ category: "mp_all",
2939
+ channel: "",
2940
+ stream_api_version: "88",
2941
+ genre_type_switch: '{"repost":1,"small_video":1,"toutiao_graphic":1,"weitoutiao":1,"xigua_video":1}',
2942
+ device_platform: "pc",
2943
+ platform_id: "0",
2944
+ visited_uid: visitedUid.user_id_str,
2945
+ offset: (pageNum - 1) * pageSize,
2946
+ count: pageSize,
2947
+ keyword: "",
2948
+ 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"}`,
2949
+ app_id: "1231"
2950
+ }
2951
+ });
2952
+ const articleCell = articleInfo.data.map((item)=>({
2953
+ title: item.assembleCell.itemCell.articleBase.title,
2954
+ imageUrl: item.assembleCell.itemCell.imageList.staggerFeedCover[0].url,
2955
+ createTime: item.assembleCell.itemCell.articleBase.publishTime,
2956
+ redirectUrl: item.assembleCell.itemCell.articleBase.articleURL,
2957
+ showNum: item.assembleCell.itemCell.itemCounter.showCount,
2958
+ readNum: item.assembleCell.itemCell.itemCounter.readCount,
2959
+ likeNum: item.assembleCell.itemCell.itemCounter.diggCount,
2960
+ commentNum: item.assembleCell.itemCell.itemCounter.commentCount,
2961
+ ...showOriginalData ? {
2962
+ originalData: item
2963
+ } : {}
2964
+ }));
2965
+ const api_base_info_json = JSON.parse(articleInfo.api_base_info.app_extra_params);
2966
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
2967
+ articleCell,
2968
+ ...onlySuccess ? {
2969
+ pagination: {
2970
+ total: api_base_info_json.total_count || -1,
2971
+ pageNum,
2972
+ pageSize
2973
+ }
2974
+ } : null
2975
+ }, "头条号文章文章获取成功");
2976
+ } catch (error) {
2977
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "头条号文章数据获取失败");
2978
+ }
2979
+ }
2980
+ async function handleWeixinData(params) {
2981
+ try {
2982
+ const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
2983
+ if (!token) return {
2984
+ code: 200,
2985
+ message: "缺少token",
2986
+ data: null
2987
+ };
2988
+ const http = new Http({
2989
+ headers: {
2990
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";")
2991
+ }
2992
+ });
2993
+ const ParsePublishPage = (body)=>{
2994
+ const match = body.match(/publish_page\s*=\s*({[\s\S]*?});/);
2995
+ if (!match) throw new Error('无法提取 publish_page 字段');
2996
+ let parsedData = JSON.parse(match[1]);
2997
+ const decodeEntities = function(str, decode = false) {
2998
+ const encodeMap = [
2999
+ "&",
3000
+ "&amp;",
3001
+ "<",
3002
+ "&lt;",
3003
+ ">",
3004
+ "&gt;",
3005
+ " ",
3006
+ "&nbsp;",
3007
+ '"',
3008
+ "&quot;",
3009
+ "'",
3010
+ "&#39;"
3011
+ ];
3012
+ const decodeMap = [
3013
+ "&#39;",
3014
+ "'",
3015
+ "&quot;",
3016
+ '"',
3017
+ "&nbsp;",
3018
+ " ",
3019
+ "&gt;",
3020
+ ">",
3021
+ "&lt;",
3022
+ "<",
3023
+ "&amp;",
3024
+ "&",
3025
+ "&#60;",
3026
+ "<",
3027
+ "&#62;",
3028
+ ">"
3029
+ ];
3030
+ const map = decode ? decodeMap : encodeMap;
3031
+ let result = str;
3032
+ for(let i = 0; i < map.length; i += 2)result = result.replace(new RegExp(map[i], "g"), map[i + 1]);
3033
+ return result;
3034
+ };
3035
+ const finalData = {
3036
+ ...parsedData,
3037
+ publish_list: parsedData.publish_list.map((item)=>{
3038
+ const decoded = decodeEntities(item.publish_info, true);
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
+ async function fetchArticles(begin, pageSize, token) {
3049
+ return http.api({
3050
+ method: "get",
3051
+ url: 'https://mp.weixin.qq.com/cgi-bin/appmsgpublish',
3052
+ params: {
3053
+ sub: "list",
3054
+ begin: begin,
3055
+ count: pageSize,
3056
+ token: token,
3057
+ lang: "zh_CN"
3058
+ }
3059
+ });
3060
+ }
3061
+ let size = pageSize > 20 ? 20 : pageSize;
3062
+ let rawArticlesInfo = await fetchArticles((pageNum - 1) * size, size, token);
3063
+ let articlesInfo = ParsePublishPage(rawArticlesInfo);
3064
+ if (!onlySuccess && pageSize > 20) {
3065
+ let totalFetched = articlesInfo.publish_list.length;
3066
+ let nextPage = pageNum + 1;
3067
+ while(totalFetched < pageSize){
3068
+ const remaining = pageSize - totalFetched;
3069
+ const currentPageSize = remaining > 20 ? 20 : remaining;
3070
+ let _rawArticlesInfo = await fetchArticles((nextPage - 1) * 20, currentPageSize, token);
3071
+ let parsed = ParsePublishPage(_rawArticlesInfo);
3072
+ articlesInfo.publish_list = articlesInfo.publish_list.concat(parsed.publish_list);
3073
+ totalFetched = articlesInfo.publish_list.length;
3074
+ if (parsed.publish_list.length < currentPageSize) break;
3075
+ nextPage++;
3076
+ }
3077
+ }
3078
+ const articleCell = articlesInfo?.publish_list.map((item)=>({
3079
+ title: item.publish_info.appmsg_info[0].title,
3080
+ imageUrl: item.publish_info.appmsg_info[0].cover,
3081
+ createTime: item.publish_info.appmsg_info[0].line_info.send_time,
3082
+ redirectUrl: item.publish_info.appmsg_info[0].content_url,
3083
+ readNum: item.publish_info.appmsg_info[0].read_num,
3084
+ likeNum: item.publish_info.appmsg_info[0].old_like_num,
3085
+ shareNum: item.publish_info.appmsg_info[0].share_num,
3086
+ recommendNum: item.publish_info.appmsg_info[0].like_num,
3087
+ ...showOriginalData ? {
3088
+ originalData: item
3089
+ } : {}
3090
+ }));
3091
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
3092
+ articleCell,
3093
+ ...onlySuccess ? {
3094
+ pagination: {
3095
+ total: articlesInfo?.total_count,
3096
+ pageNum,
3097
+ pageSize
3098
+ }
3099
+ } : null
3100
+ }, "微信文章文章获取成功");
3101
+ } catch (error) {
3102
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "微信文章数据获取失败");
3103
+ }
3104
+ }
3105
+ async function handleBaijiahaoData(params) {
3106
+ try {
3107
+ const { cookies, token, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3108
+ if (!token) return {
3109
+ code: 200,
3110
+ message: "缺少token",
3111
+ data: null
3112
+ };
3113
+ const http = new Http({
3114
+ headers: {
3115
+ cookie: cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3116
+ token: token
3117
+ }
3118
+ });
3119
+ async function fetchArticles(pageNum, pageSize, onlySuccess = false) {
3120
+ return await http.api({
3121
+ method: "get",
3122
+ url: "https://baijiahao.baidu.com/pcui/article/lists",
3123
+ params: {
3124
+ currentPage: pageNum,
3125
+ pageSize: pageSize,
3126
+ search: "",
3127
+ type: "",
3128
+ collection: onlySuccess ? "publish" : "",
3129
+ clearBeforeFetch: false,
3130
+ dynamic: 1
3131
+ }
3132
+ });
3133
+ }
3134
+ const articleInfo = await fetchArticles(pageNum, pageSize, onlySuccess);
3135
+ let filtered = articleInfo.data.list.filter((item)=>"draft" !== item.status);
3136
+ const totalPage = articleInfo.data.page?.totalPage || 1;
3137
+ let currentPage = pageNum + 1;
3138
+ const usedPages = new Set();
3139
+ while(filtered.length < pageSize && currentPage <= totalPage){
3140
+ if (usedPages.has(currentPage)) {
3141
+ currentPage++;
3142
+ continue;
3143
+ }
3144
+ const res = await fetchArticles(currentPage, pageSize, onlySuccess);
3145
+ usedPages.add(currentPage);
3146
+ const validItems = res.data.list.filter((item)=>"draft" !== item.status);
3147
+ filtered.push(...validItems);
3148
+ currentPage++;
3149
+ }
3150
+ const final = filtered.slice(0, pageSize);
3151
+ const articleCell = final.map((item)=>({
3152
+ title: item.title,
3153
+ imageUrl: JSON.parse(item.cover_images)[0].src,
3154
+ createTime: Math.floor(new Date(item.publish_at.replace(/-/g, "/")).getTime() / 1000),
3155
+ redirectUrl: item.url,
3156
+ recommendNum: item.rec_amount,
3157
+ collectNum: item.collection_amount,
3158
+ readNum: item.read_amount,
3159
+ likeNum: item.like_amount,
3160
+ commentNum: item.comment_amount,
3161
+ shareNum: item.share_amount,
3162
+ ...showOriginalData ? {
3163
+ originalData: item
3164
+ } : {}
3165
+ }));
3166
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
3167
+ articleCell,
3168
+ ...onlySuccess ? {
3169
+ pagination: {
3170
+ total: articleInfo.data.page?.totalCount,
3171
+ pageNum,
3172
+ pageSize
3173
+ }
3174
+ } : null
3175
+ }, "百家号文章数据获取成功");
3176
+ } catch (error) {
3177
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "百家号文章数据获取失败");
3178
+ }
3179
+ }
3180
+ async function handleXiaohongshuData(params) {
3181
+ try {
3182
+ const { cookies, pageNum = 1, pageSize = 10, showOriginalData = false, onlySuccess = false } = params;
3183
+ const xsEncrypt = new XsEncrypt();
3184
+ const a1Cookie = cookies.find((it)=>"a1" === it.name)?.value;
3185
+ if (!a1Cookie) return {
3186
+ code: 200,
3187
+ message: "账号数据异常",
3188
+ data: null
3189
+ };
3190
+ if (onlySuccess && 10 != pageSize) return {
3191
+ code: 200,
3192
+ message: "小红书pageSize不可修改",
3193
+ data: null
3194
+ };
3195
+ const http = new Http({
3196
+ headers: {
3197
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
3198
+ referer: "https://creator.xiaohongshu.com",
3199
+ origin: "https://creator.xiaohongshu.com"
3200
+ }
3201
+ });
3202
+ async function fetchArticles(pageNum, a1Cookie, onlySuccess = false) {
3203
+ const xt = Date.now().toString();
3204
+ const serveUrl = `/web_api/sns/v5/creator/note/user/posted?tab=${onlySuccess ? 1 : 0}&page=${pageNum - 1}`;
3205
+ const xs = await xsEncrypt.encryptXs(serveUrl, a1Cookie, xt);
3206
+ return await http.api({
3207
+ method: "get",
3208
+ baseURL: "https://edith.xiaohongshu.com",
3209
+ url: serveUrl,
3210
+ headers: {
3211
+ "x-s": xs,
3212
+ "x-t": xt
3213
+ }
3214
+ });
3215
+ }
3216
+ const articleInfo = await fetchArticles(pageNum, a1Cookie, onlySuccess);
3217
+ let hasNextpage = -1 != articleInfo.data.page;
3218
+ let filtered = articleInfo.data.notes;
3219
+ let currentPage = pageNum + 1;
3220
+ const usedPages = new Set();
3221
+ while(filtered.length < pageSize && hasNextpage){
3222
+ if (usedPages.has(currentPage)) {
3223
+ currentPage++;
3224
+ continue;
3225
+ }
3226
+ const res = await fetchArticles(currentPage, a1Cookie, onlySuccess);
3227
+ usedPages.add(currentPage);
3228
+ const validItems = res.data.notes;
3229
+ filtered.push(...validItems);
3230
+ currentPage++;
3231
+ hasNextpage = -1 != res.data.page;
3232
+ }
3233
+ const final = filtered.slice(0, pageSize);
3234
+ const articleCell = final.map((item)=>({
3235
+ title: item.display_title,
3236
+ imageUrl: item.images_list[0].url,
3237
+ createTime: Math.floor(new Date(item.time.replace(/-/g, "/")).getTime() / 1000),
3238
+ redirectUrl: `https://www.xiaohongshu.com/explore/${item.id}?xsec_token=${item.xsec_token}&xsec_source=pc_creatormng`,
3239
+ readNum: item.view_count,
3240
+ likeNum: item.likes,
3241
+ commentNum: item.comments_count,
3242
+ collectNum: item.collected_count,
3243
+ shareNum: item.shared_count,
3244
+ ...showOriginalData ? {
3245
+ originalData: item
3246
+ } : {}
3247
+ }));
3248
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)({
3249
+ articleCell,
3250
+ ...onlySuccess ? {
3251
+ pagination: {
3252
+ nextPage: hasNextpage,
3253
+ pageNum,
3254
+ pageSize
3255
+ }
3256
+ } : null
3257
+ }, "小红书文章数据获取成功");
3258
+ } catch (error) {
3259
+ return searchPublishInfo_types_errorResponse(error instanceof Error ? error.message : "小红书文章数据获取失败");
3260
+ }
3261
+ }
3262
+ const FetchArticles = async (_task, params)=>{
3263
+ const { platform } = params;
3264
+ switch(platform){
3265
+ case "toutiao":
3266
+ return handleToutiaoData(params);
3267
+ case "weixin":
3268
+ return handleWeixinData(params);
3269
+ case "baijiahao":
3270
+ return handleBaijiahaoData(params);
3271
+ case "xiaohongshu":
3272
+ return handleXiaohongshuData(params);
3273
+ default:
3274
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(null, "暂不支持该平台");
3275
+ }
3276
+ };
3277
+ const getWeixinConfig = async (_task, params)=>{
3278
+ const http = new Http({
3279
+ headers: {
3280
+ cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";")
3281
+ }
3282
+ });
3283
+ const fingerprint = "4695500bc93ab4ce8fb2692da6564e04";
3284
+ const res = await http.api({
3285
+ method: "get",
3286
+ url: "https://mp.weixin.qq.com/cgi-bin/masssendpage",
3287
+ params: {
3288
+ f: 'json',
3289
+ token: params.token,
3290
+ lang: 'zh_CN',
3291
+ ajax: 1,
3292
+ fingerprint: fingerprint,
3293
+ random: Math.random().toString()
3294
+ }
3295
+ });
3296
+ const filtered = {
3297
+ publishQuota: 0 === res.base_resp.ret ? res.quota_detail_list.filter((item)=>"kQuotaTypeMassSendNormal" === item.quota_type).map((item)=>item.quota_item_list) : []
3298
+ };
3299
+ return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(filtered, 0 === res.base_resp.ret ? "微信配置信息获取成功!" : "微信配置信息获取失败!");
3300
+ };
2566
3301
  const weitoutiaoPublish_mock_mockAction = async (task, params)=>{
2567
3302
  const tmpCachePath = task.getTmpPath();
2568
3303
  const http = new Http({
@@ -4525,9 +5260,7 @@ const xiaohongshuPublish = async (task, params)=>{
4525
5260
  if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
4526
5261
  return executeAction(xiaohongshuPublish_mock_mockAction, xiaohongshuPublish_rpa_rpaAction)(task, params);
4527
5262
  };
4528
- var package_namespaceObject = {
4529
- i8: "1.2.14"
4530
- };
5263
+ var package_namespaceObject = JSON.parse('{"i8":"1.2.16-beta.0"}');
4531
5264
  class Action {
4532
5265
  constructor(task){
4533
5266
  this.task = task;
@@ -4548,6 +5281,24 @@ class Action {
4548
5281
  } else this.task.logger.info(`${func.name} action success`);
4549
5282
  return responseData;
4550
5283
  }
5284
+ FetchArticles(params) {
5285
+ return this.bindTask(FetchArticles, params);
5286
+ }
5287
+ SearchAccountInfo(params) {
5288
+ return this.bindTask(SearchAccountInfo, params);
5289
+ }
5290
+ TTSessionCheck(params) {
5291
+ return this.bindTask(TTSessionCheck, params);
5292
+ }
5293
+ WxSessionCheck(params) {
5294
+ return this.bindTask(WxSessionCheck, params);
5295
+ }
5296
+ XhsSessionCheck(params) {
5297
+ return this.bindTask(XhsSessionCheck, params);
5298
+ }
5299
+ BjhSessionCheck(params) {
5300
+ return this.bindTask(BjhSessionCheck, params);
5301
+ }
4551
5302
  searchToutiaoTopicList(params) {
4552
5303
  return this.bindTask(searchToutiaoTopicList, params);
4553
5304
  }
@@ -4572,6 +5323,9 @@ class Action {
4572
5323
  getToutiaoConfig(params) {
4573
5324
  return this.bindTask(getToutiaoConfig, params);
4574
5325
  }
5326
+ getWeixinConfig(params) {
5327
+ return this.bindTask(getWeixinConfig, params);
5328
+ }
4575
5329
  getBaijiahaoConfig(params) {
4576
5330
  return this.bindTask(getBaijiahaoConfig, params);
4577
5331
  }