publishport-opencli 1.0.11 → 1.0.12

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/cli-manifest.json CHANGED
@@ -47382,6 +47382,48 @@
47382
47382
  "sourceFile": "xianyu/item.js",
47383
47383
  "navigateBefore": false
47384
47384
  },
47385
+ {
47386
+ "site": "xianyu",
47387
+ "name": "item-stats",
47388
+ "description": "读每个在售商品的经营数据(曝光/浏览/询单/支付/退款,逐商品一行)",
47389
+ "access": "read",
47390
+ "domain": "seller.goofish.com",
47391
+ "strategy": "cookie",
47392
+ "browser": true,
47393
+ "args": [
47394
+ {
47395
+ "name": "range",
47396
+ "type": "str",
47397
+ "default": "recent1d",
47398
+ "required": false,
47399
+ "help": "时间范围:recent1d / recent7d / recent30d"
47400
+ }
47401
+ ],
47402
+ "columns": [
47403
+ "itemId",
47404
+ "title",
47405
+ "price",
47406
+ "exposureCount",
47407
+ "exposureUsers",
47408
+ "viewCount",
47409
+ "viewUsers",
47410
+ "inquiryUsers",
47411
+ "payUsers",
47412
+ "payOrders",
47413
+ "payAmount",
47414
+ "viewPayCvr",
47415
+ "refundUsers",
47416
+ "refundOrders",
47417
+ "refundAmount",
47418
+ "refundOkUsers",
47419
+ "refundOkOrders",
47420
+ "refundOkAmount"
47421
+ ],
47422
+ "type": "js",
47423
+ "modulePath": "xianyu/item-stats.js",
47424
+ "sourceFile": "xianyu/item-stats.js",
47425
+ "navigateBefore": false
47426
+ },
47385
47427
  {
47386
47428
  "site": "xianyu",
47387
47429
  "name": "location",
@@ -47715,6 +47757,33 @@
47715
47757
  "sourceFile": "xianyu/manage.js",
47716
47758
  "navigateBefore": false
47717
47759
  },
47760
+ {
47761
+ "site": "xianyu",
47762
+ "name": "promote-stats",
47763
+ "description": "读超级擦亮(付费推广)投放数据:花费/曝光/点击/询单/下单/单次成本 + 账户余额 + 计划状态",
47764
+ "access": "read",
47765
+ "domain": "seller.goofish.com",
47766
+ "strategy": "cookie",
47767
+ "browser": true,
47768
+ "args": [
47769
+ {
47770
+ "name": "range",
47771
+ "type": "str",
47772
+ "default": "today",
47773
+ "required": false,
47774
+ "help": "时间范围:today / yesterday / recent7d / recent30d / recent90d"
47775
+ }
47776
+ ],
47777
+ "columns": [
47778
+ "metric",
47779
+ "value",
47780
+ "compare"
47781
+ ],
47782
+ "type": "js",
47783
+ "modulePath": "xianyu/promote-stats.js",
47784
+ "sourceFile": "xianyu/promote-stats.js",
47785
+ "navigateBefore": false
47786
+ },
47718
47787
  {
47719
47788
  "site": "xianyu",
47720
47789
  "name": "publish",
@@ -47949,6 +48018,62 @@
47949
48018
  "sourceFile": "xianyu/search.js",
47950
48019
  "navigateBefore": false
47951
48020
  },
48021
+ {
48022
+ "site": "xianyu",
48023
+ "name": "seller-data",
48024
+ "description": "读卖家工作台经营数据(曝光/访问/浏览/转化/复购/售后等指标卡)",
48025
+ "access": "read",
48026
+ "domain": "seller.goofish.com",
48027
+ "strategy": "cookie",
48028
+ "browser": true,
48029
+ "args": [
48030
+ {
48031
+ "name": "page",
48032
+ "type": "str",
48033
+ "default": "overview",
48034
+ "required": false,
48035
+ "help": "数据页:overview / commodity / fans / service"
48036
+ },
48037
+ {
48038
+ "name": "range",
48039
+ "type": "str",
48040
+ "default": "recent1d",
48041
+ "required": false,
48042
+ "help": "时间范围:recent1d / recent7d / recent30d"
48043
+ }
48044
+ ],
48045
+ "columns": [
48046
+ "metric",
48047
+ "value",
48048
+ "compare"
48049
+ ],
48050
+ "type": "js",
48051
+ "modulePath": "xianyu/seller-data.js",
48052
+ "sourceFile": "xianyu/seller-data.js",
48053
+ "navigateBefore": false
48054
+ },
48055
+ {
48056
+ "site": "xianyu",
48057
+ "name": "seller-list",
48058
+ "description": "读卖家工作台列表页(refund / review / complaint / income / expense / shipping-template)—— 表头即列,动态返回",
48059
+ "access": "read",
48060
+ "domain": "seller.goofish.com",
48061
+ "strategy": "cookie",
48062
+ "browser": true,
48063
+ "args": [
48064
+ {
48065
+ "name": "page",
48066
+ "type": "str",
48067
+ "required": true,
48068
+ "positional": true,
48069
+ "help": "列表页:refund / review / complaint / income / expense / shipping-template"
48070
+ }
48071
+ ],
48072
+ "type": "js",
48073
+ "modulePath": "xianyu/seller-list.js",
48074
+ "sourceFile": "xianyu/seller-list.js",
48075
+ "navigateBefore": false
48076
+ },
47952
48077
  {
47953
48078
  "site": "xianyu",
47954
48079
  "name": "user",
@@ -0,0 +1,2 @@
1
+ import{CommandExecutionError as Y,ArgumentError as O}from"@jackwener/opencli/errors";import{cli as P,Strategy as f}from"@jackwener/opencli/registry";const $={recent1d:"近1天",recent7d:"近7天",recent30d:"近30天"},C="https://seller.goofish.com/?site=COMMONPRO#/seller-data/commodity",b={商品曝光次数:"exposureCount",商品曝光人数:"exposureUsers",商品浏览次数:"viewCount",商品浏览人数:"viewUsers",询单人数:"inquiryUsers",支付人数:"payUsers",支付订单数:"payOrders",支付金额:"payAmount",浏览支付转化率:"viewPayCvr",发起退款人数:"refundUsers",发起退款订单数:"refundOrders",发起退款金额:"refundAmount",成功退款人数:"refundOkUsers",成功退款订单数:"refundOkOrders",成功退款金额:"refundOkAmount"};function j(q){const W=Array.from(document.querySelectorAll("thead th")).map((z)=>(z.innerText||"").trim());if(!W.length)return{error:"no-table"};const F={};W.forEach((z,v)=>{if(q[z]!=null)F[q[z]]=v});const J=[];document.querySelectorAll("tbody tr").forEach((z)=>{const v=Array.from(z.querySelectorAll("td"));if(!v.length)return;if(v.every((V)=>!(V.innerText||"").trim()))return;const Q=(v[0].innerText||"").replace(/\r/g,""),B=Q.match(/(\d{10,})/),L=Q.match(/¥\s*([\d.]+)/),H=Q.split(`
2
+ `).map((V)=>V.trim()).filter(Boolean)[0]||"";if(!B)return;const S={itemId:B[1],title:H,price:L?L[1]:""};for(const V of Object.keys(q)){const U=q[V],Z=F[U];S[U]=Z!=null&&v[Z]?(v[Z].innerText||"").trim():""}J.push(S)});return{rows:J}}P({site:"xianyu",name:"item-stats",access:"read",description:"读每个在售商品的经营数据(曝光/浏览/询单/支付/退款,逐商品一行)",domain:"seller.goofish.com",strategy:f.COOKIE,navigateBefore:!1,browser:!0,args:[{name:"range",default:"recent1d",help:"时间范围:recent1d / recent7d / recent30d"}],columns:["itemId","title","price","exposureCount","exposureUsers","viewCount","viewUsers","inquiryUsers","payUsers","payOrders","payAmount","viewPayCvr","refundUsers","refundOrders","refundAmount","refundOkUsers","refundOkOrders","refundOkAmount"],func:async(q,W)=>{const F=String(W.range||"recent1d").trim(),J=$[F];if(!J)throw new O(`--range 只能是 ${Object.keys($).join(" / ")},收到 "${F}"`);await q.goto(C);await q.wait(3);if(F!=="recent1d"){await q.evaluate((Q)=>{Array.from(document.querySelectorAll("label,span,div,button")).filter((B)=>B.children.length===0&&(B.innerText||"").trim()===Q).forEach((B)=>B.click())},J);await q.wait(2)}const z=await q.evaluate(j,b);if(z.error==="no-table")throw new Y("商品数据表未渲染 —— 可能未登录卖家中心 / 页面改版 / 无权限");const v=z.rows||[];if(v.length===0)throw new Y("商品数据表为空 —— 该账号可能无在售商品或当前范围无数据");return v}});export const __test__={readItemTable:j,HEADER_MAP:b,RANGE_TEXT:$};
@@ -0,0 +1,2 @@
1
+ import{CommandExecutionError as C,ArgumentError as H}from"@jackwener/opencli/errors";import{cli as M,Strategy as O}from"@jackwener/opencli/registry";const Z={today:"今日",yesterday:"昨日",recent7d:"近7日",recent30d:"近30日",recent90d:"近90日"},S="https://seller.goofish.com/?site=COMMONPRO#/seller-ad/home";function $(){const B=[],I=(z,f,q)=>{if(z&&f!==""&&f!=null)B.push({metric:z,value:f,compare:q||""})};document.querySelectorAll('[class*="metricCard--"]').forEach((z)=>{const f=(z.innerText||"").split(`
2
+ `).map((U)=>U.trim()).filter(Boolean);if(f.length<2)return;const q=f[0],L=f[1],Y=f.slice(2).join(" ");I(q,L,Y)});const P=(z)=>{const f=Array.from(document.querySelectorAll("div,span")).filter((q)=>q.children.length===0&&(q.innerText||"").trim().replace(/(.*)|\(.*\)/g,"")===z);for(const q of f){let L=q.parentElement;for(let Y=0;Y<3&&L;Y++){const U=(L.innerText||"").match(/-?[\d,]+(\.\d+)?%?/);if(U&&U[0]!==z)return U[0];L=L.parentElement}}return null};[["擦亮中计划","擦亮中计划"],["已暂停擦亮计划","已暂停擦亮计划"],["即将消耗完成计划","即将消耗完成计划"],["已完成擦亮计划","已完成擦亮计划"]].forEach(([z,f])=>{const q=P(f);if(q!=null)I(z,q,"")});const Q=document.body?document.body.innerText.replace(/\s+/g," "):"",J=/[^\d-]*(-?[\d,]+(?:\s*\.\s*\d+)?)/,W=Q.match(new RegExp("可用余额[((]元[))]"+J.source));if(W)I("可用余额(元)",W[1].replace(/\s+/g,""),"");const F=Q.match(new RegExp("今日花费[((]元[))]"+J.source));if(F)I("今日花费(元)",F[1].replace(/\s+/g,""),"");return B}M({site:"xianyu",name:"promote-stats",access:"read",description:"读超级擦亮(付费推广)投放数据:花费/曝光/点击/询单/下单/单次成本 + 账户余额 + 计划状态",domain:"seller.goofish.com",strategy:O.COOKIE,navigateBefore:!1,browser:!0,args:[{name:"range",default:"today",help:"时间范围:today / yesterday / recent7d / recent30d / recent90d"}],columns:["metric","value","compare"],func:async(B,I)=>{const P=String(I.range||"today").trim(),Q=Z[P];if(!Q)throw new H(`--range 只能是 ${Object.keys(Z).join(" / ")},收到 "${P}"`);await B.goto(S);await B.wait(4);if(P!=="today"){await B.evaluate((W)=>{Array.from(document.querySelectorAll("label,span,div,button")).filter((F)=>F.children.length===0&&(F.innerText||"").trim()===W).forEach((F)=>F.click())},Q);await B.wait(2)}const J=await B.evaluate($);if(!Array.isArray(J)||J.length===0)throw new C("未读到擦亮数据 —— 可能未开通超级擦亮 / 未登录 / 页面改版");return J}});export const __test__={readAdDashboard:$,RANGE_TEXT:Z};
@@ -0,0 +1 @@
1
+ import{ArgumentError as $,CommandExecutionError as M}from"@jackwener/opencli/errors";import{cli as j,Strategy as L}from"@jackwener/opencli/registry";const V={overview:{hash:"#/seller-data/data",label:"数据总览"},commodity:{hash:"#/seller-data/commodity",label:"商品数据"},fans:{hash:"#/seller-data/fanData",label:"粉丝数据"},service:{hash:"#/seller-data/customerService",label:"客服数据"}},W={recent1d:"近1天",recent7d:"近7天",recent30d:"近30天"},x="https://seller.goofish.com/?site=COMMONPRO";function H(){const f=[],I=new Set;document.querySelectorAll('[class*="statValue--"]').forEach((B)=>{let b=B,q=null,D=null;for(let Z=0;Z<5&&b;Z++){b=b.parentElement;if(!b)break;q=b.querySelector('[class*="statHeader--"]');if(q){D=b;break}}if(!q||!D)return;const z=(q.innerText||"").trim(),Q=(B.innerText||"").trim();if(!z)return;const J=D.querySelector('[class*="statPrevious--"]'),F=J?(J.innerText||"").replace(/\s+/g," ").trim():"",Y=z+"|"+Q;if(I.has(Y))return;I.add(Y);f.push({metric:z,value:Q,compare:F})});return f}j({site:"xianyu",name:"seller-data",access:"read",description:"读卖家工作台经营数据(曝光/访问/浏览/转化/复购/售后等指标卡)",domain:"seller.goofish.com",strategy:L.COOKIE,navigateBefore:!1,browser:!0,args:[{name:"page",default:"overview",help:`数据页:${Object.keys(V).join(" / ")}`},{name:"range",default:"recent1d",help:"时间范围:recent1d / recent7d / recent30d"}],columns:["metric","value","compare"],func:async(f,I)=>{const B=String(I.page||"overview").trim(),b=V[B];if(!b)throw new $(`--page 只能是 ${Object.keys(V).join(" / ")},收到 "${B}"`);const q=String(I.range||"recent1d").trim(),D=W[q];if(!D)throw new $(`--range 只能是 ${Object.keys(W).join(" / ")},收到 "${q}"`);await f.goto(`${x}${b.hash}`);await f.wait(3);if(q!=="recent1d"){await f.evaluate((Q)=>{const J=Array.from(document.querySelectorAll("label,span,div,button")).filter((F)=>F.children.length===0&&(F.innerText||"").trim()===Q);J.forEach((F)=>F.click());return J.length},D);await f.wait(2)}const z=await f.evaluate(H);if(!Array.isArray(z)||z.length===0)throw new M(`未读到任何指标卡(page=${B})—— 可能未登录卖家中心、页面结构改版或该账号无权限`);return z}});export const __test__={readCards:H,PAGE_ROUTES:V,RANGE_TEXT:W};
@@ -0,0 +1 @@
1
+ import{CommandExecutionError as M,ArgumentError as V}from"@jackwener/opencli/errors";import{cli as W,Strategy as X}from"@jackwener/opencli/registry";const D={refund:{hash:"#/seller-trade/refund-manage",label:"退款管理"},review:{hash:"#/seller-trade/evaluation-manage",label:"评价管理"},complaint:{hash:"#/seller-trade/complaint-manage",label:"投诉管理"},income:{hash:"#/seller-finance/income-bill",label:"收入账单"},expense:{hash:"#/seller-finance/expense-bill",label:"支出账单"},"shipping-template":{hash:"#/seller-item/post-temple",label:"运费模版"}};function N(){const q=Array.from(document.querySelectorAll("thead th")).map((z)=>(z.innerText||"").trim()).filter(Boolean);if(!q.length)return{error:"no-table"};const F=[];let B=!1;document.querySelectorAll("tbody tr").forEach((z)=>{const f=Array.from(z.querySelectorAll("td"));if(!f.length)return;if(f.every((I)=>!(I.innerText||"").trim()))return;if(f.length===1)return;if(f.length!==q.length){B=!0;return}const H={};f.forEach((I,L)=>{const Q=q[L]||`col${L+1}`;H[Q]=(I.innerText||"").replace(/\s+/g," ").trim()});const J=Object.values(H).filter(Boolean);if(J.length<=1&&/^(暂无数据|没有数据|暂无记录|空空如也)$/.test(J[0]||""))return;F.push(H)});return{heads:q,rows:F,misaligned:B}}W({site:"xianyu",name:"seller-list",access:"read",description:`读卖家工作台列表页(${Object.keys(D).join(" / ")})—— 表头即列,动态返回`,domain:"seller.goofish.com",strategy:X.COOKIE,navigateBefore:!1,browser:!0,args:[{name:"page",required:!0,positional:!0,help:`列表页:${Object.keys(D).join(" / ")}`}],func:async(q,F)=>{const B=String(F.page||"").trim(),z=D[B];if(!z)throw new V(`page 只能是 ${Object.keys(D).join(" / ")},收到 "${B}"`);await q.goto(`https://seller.goofish.com/?site=COMMONPRO${z.hash}`);await q.wait(4);const f=await q.evaluate(N);if(f.error==="no-table")throw new M(`${z.label} 未渲染出表格 —— 可能未登录 / 页面改版 / 无权限`);if(f.misaligned&&(f.rows||[]).length===0)throw new M(`${z.label} 表格单元格数与表头(${(f.heads||[]).length}列)不一致,疑似带选择/展开列,需为该页单独适配以免列错位`);return f.rows||[]}});export const __test__={readTable:N,PAGE_ROUTES:D};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publishport-opencli",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false