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