@iflyrpa/actions 1.2.16 → 1.2.17

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