@iflyrpa/actions 3.0.2 → 3.0.4
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/bundle.js +1712 -718
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +1831 -839
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1831 -839
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -5435,7 +5435,7 @@ function __webpack_require__(moduleId) {
|
|
|
5435
5435
|
};
|
|
5436
5436
|
})();
|
|
5437
5437
|
var package_namespaceObject = {
|
|
5438
|
-
i8: "3.0.
|
|
5438
|
+
i8: "3.0.3"
|
|
5439
5439
|
};
|
|
5440
5440
|
var dist = __webpack_require__("../../node_modules/.pnpm/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js");
|
|
5441
5441
|
async function ProxyAgent(task, ip, adr, accountId, refresh) {
|
|
@@ -5451,7 +5451,7 @@ async function ProxyAgent(task, ip, adr, accountId, refresh) {
|
|
|
5451
5451
|
};
|
|
5452
5452
|
const ProxyInfo = await http.api({
|
|
5453
5453
|
method: "POST",
|
|
5454
|
-
url: "
|
|
5454
|
+
url: "https://fetdev.iflysec.com/ip-pool/pool/eip/proxy",
|
|
5455
5455
|
data: params
|
|
5456
5456
|
}).catch((err)=>{
|
|
5457
5457
|
throw {
|
|
@@ -9624,7 +9624,7 @@ const types_errorResponse = (message, code = 500)=>({
|
|
|
9624
9624
|
data: null
|
|
9625
9625
|
});
|
|
9626
9626
|
const MockPublish = false;
|
|
9627
|
-
const DisabledReq =
|
|
9627
|
+
const DisabledReq = false;
|
|
9628
9628
|
const scanRetryMaxCount = 60;
|
|
9629
9629
|
const waitQrcodeResultMaxTime = 2000 * scanRetryMaxCount;
|
|
9630
9630
|
const rpaServer = async (task, params)=>{
|
|
@@ -14483,29 +14483,54 @@ const mock_mockAction = async (task, params)=>{
|
|
|
14483
14483
|
})}`);
|
|
14484
14484
|
task.logger.info(`publishData: ${JSON.stringify(publishData)}`);
|
|
14485
14485
|
task.logger.info(`url: https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`);
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
|
|
14507
|
-
|
|
14508
|
-
|
|
14486
|
+
let publishResult;
|
|
14487
|
+
try {
|
|
14488
|
+
publishResult = await proxyHttp.api({
|
|
14489
|
+
method: "post",
|
|
14490
|
+
url: `https://creator.douyin.com/web/api/media/aweme/create_v2/?${publishQueryParams}`,
|
|
14491
|
+
data: publishData,
|
|
14492
|
+
defaultErrorMsg: "发布异常,请稍后重试。",
|
|
14493
|
+
headers: {
|
|
14494
|
+
...headers,
|
|
14495
|
+
Referer: "https://creator.douyin.com/creator-micro/content/post/image?default-tab=3&enter_from=publish_page&media_type=image&type=new",
|
|
14496
|
+
"Content-Type": "application/json",
|
|
14497
|
+
Accept: "application/json, text/plain, */*",
|
|
14498
|
+
"bd-ticket-guard-client-data": bdTicketGuardClientData["headers_bd_ticket_guard_client_data"],
|
|
14499
|
+
"bd-ticket-guard-ree-public-key": bdTicketGuardClientData["headers_bd_ticket_guard_ree_public_key"],
|
|
14500
|
+
"bd-ticket-guard-version": "2",
|
|
14501
|
+
"bd-ticket-guard-web-sign-type": "1",
|
|
14502
|
+
"bd-ticket-guard-web-version": "2",
|
|
14503
|
+
"x-secsdk-csrf-token": csrfToken,
|
|
14504
|
+
"x-tt-session-dtrait": sessionDtrait || ""
|
|
14505
|
+
}
|
|
14506
|
+
}, {
|
|
14507
|
+
timeout: 60000,
|
|
14508
|
+
retries: 3,
|
|
14509
|
+
retryDelay: 2000
|
|
14510
|
+
});
|
|
14511
|
+
} catch (error) {
|
|
14512
|
+
const upstreamMessage = error?.message || String(error);
|
|
14513
|
+
const upstreamCode = error?.code;
|
|
14514
|
+
task.logger.error(`TaskId:${task.taskId},create_v2 请求异常,上游错误已屏蔽。上游 code=${upstreamCode},message=${upstreamMessage}`, {
|
|
14515
|
+
error,
|
|
14516
|
+
upstreamData: error?.data,
|
|
14517
|
+
extra: error?.extra
|
|
14518
|
+
});
|
|
14519
|
+
const message = "发布失败,请重试";
|
|
14520
|
+
await updateTaskState?.({
|
|
14521
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
14522
|
+
error: message,
|
|
14523
|
+
result: {
|
|
14524
|
+
data: decision,
|
|
14525
|
+
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
14526
|
+
}
|
|
14527
|
+
});
|
|
14528
|
+
return {
|
|
14529
|
+
code: 414,
|
|
14530
|
+
data: "",
|
|
14531
|
+
message
|
|
14532
|
+
};
|
|
14533
|
+
}
|
|
14509
14534
|
reportLogger({
|
|
14510
14535
|
token: params.huiwenToken || "",
|
|
14511
14536
|
enverionment: task.enverionment || "development",
|
|
@@ -23206,697 +23231,626 @@ const xiaohongshuLogin = async (task, params)=>{
|
|
|
23206
23231
|
if ("server" === params.actionType) return xiaohongshuLogin_rpa_server_rpaServer(task, params);
|
|
23207
23232
|
return executeAction(xiaohongshuLogin_rpa_rpaAction)(task, params);
|
|
23208
23233
|
};
|
|
23209
|
-
|
|
23210
|
-
|
|
23211
|
-
|
|
23212
|
-
|
|
23213
|
-
|
|
23214
|
-
}
|
|
23215
|
-
|
|
23216
|
-
|
|
23217
|
-
|
|
23218
|
-
|
|
23219
|
-
|
|
23220
|
-
|
|
23221
|
-
|
|
23222
|
-
|
|
23223
|
-
|
|
23224
|
-
|
|
23225
|
-
}
|
|
23226
|
-
|
|
23227
|
-
|
|
23228
|
-
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
|
|
23233
|
-
|
|
23234
|
-
|
|
23235
|
-
|
|
23236
|
-
|
|
23237
|
-
|
|
23238
|
-
|
|
23239
|
-
|
|
23240
|
-
|
|
23241
|
-
|
|
23242
|
-
|
|
23243
|
-
|
|
23244
|
-
|
|
23245
|
-
|
|
23246
|
-
|
|
23247
|
-
|
|
23248
|
-
|
|
23249
|
-
|
|
23250
|
-
|
|
23251
|
-
|
|
23252
|
-
|
|
23253
|
-
|
|
23254
|
-
}
|
|
23255
|
-
|
|
23234
|
+
let _windowCache = null;
|
|
23235
|
+
const getWindow = ()=>{
|
|
23236
|
+
if (_windowCache) return _windowCache;
|
|
23237
|
+
_windowCache = "undefined" != typeof window ? window : globalThis;
|
|
23238
|
+
return _windowCache;
|
|
23239
|
+
};
|
|
23240
|
+
if ("undefined" != typeof process) {
|
|
23241
|
+
process.on("uncaughtException", ()=>{});
|
|
23242
|
+
process.on("unhandledRejection", ()=>{});
|
|
23243
|
+
}
|
|
23244
|
+
const mnsv2_enc = (arg1, arg2, cookieString)=>{
|
|
23245
|
+
const win = getWindow();
|
|
23246
|
+
win.ck = cookieString;
|
|
23247
|
+
__webpack_require__("./src/utils/xhs_ob_feed/ob.env.js");
|
|
23248
|
+
try {
|
|
23249
|
+
__webpack_require__("./src/utils/xhs_ob_feed/ob.enc.js");
|
|
23250
|
+
} catch {}
|
|
23251
|
+
let result = "";
|
|
23252
|
+
try {
|
|
23253
|
+
result = win.mnsv2(arg1, arg2);
|
|
23254
|
+
} catch {}
|
|
23255
|
+
return result;
|
|
23256
|
+
};
|
|
23257
|
+
const mnsvc2 = mnsv2_enc;
|
|
23258
|
+
const xhs_ob_feed_encode_mnsv2 = __webpack_require__("./src/utils/xhs_ob_feed/x_s.encoder.js");
|
|
23259
|
+
class xhs_ob_feed_Xhshow {
|
|
23260
|
+
stringifyCookies(cookies) {
|
|
23261
|
+
return Object.entries(cookies).map(([key, value])=>`${key}=${value}`).join("; ");
|
|
23262
|
+
}
|
|
23263
|
+
signHeadersGet(uri, cookieString, xsecAppid = "ugc", params) {
|
|
23264
|
+
let para1 = "";
|
|
23265
|
+
if (params && 0 !== Object.keys(params).length) {
|
|
23266
|
+
const _queryPara = Object.entries(params).map(([key, value])=>{
|
|
23267
|
+
let valueStr = "";
|
|
23268
|
+
if (Array.isArray(value)) valueStr = value.map((v)=>String(v)).join(",");
|
|
23269
|
+
else if (null != value) valueStr = String(value);
|
|
23270
|
+
return `${key}=${valueStr}`;
|
|
23271
|
+
});
|
|
23272
|
+
para1 = `${uri}?${_queryPara.join("&")}`;
|
|
23273
|
+
} else para1 = uri;
|
|
23274
|
+
const md5Para1 = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(para1).digest("hex");
|
|
23275
|
+
const mnsvc2_data = mnsvc2(para1, md5Para1, this.stringifyCookies(cookieString));
|
|
23276
|
+
return {
|
|
23277
|
+
"X-S": xhs_ob_feed_encode_mnsv2(mnsvc2_data, xsecAppid, "Windows", "object")
|
|
23278
|
+
};
|
|
23279
|
+
}
|
|
23280
|
+
signHeadersPost(uri, cookieString, xsecAppid = "ugc", payload) {
|
|
23281
|
+
const para1 = uri + JSON.stringify(payload || {});
|
|
23282
|
+
const md5Para1 = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(para1).digest("hex");
|
|
23283
|
+
const mnsvc2_data = mnsvc2(para1, md5Para1, this.stringifyCookies(cookieString));
|
|
23284
|
+
return {
|
|
23285
|
+
"X-S": xhs_ob_feed_encode_mnsv2(mnsvc2_data, xsecAppid, "Windows", "object")
|
|
23286
|
+
};
|
|
23287
|
+
}
|
|
23288
|
+
}
|
|
23289
|
+
const xiaohongshuPublish_mock_errnoMap = {
|
|
23290
|
+
"-1": "未知拦截器错误,请稍后重试。",
|
|
23291
|
+
915: "所属C端账号手机号被修改,请重新登录",
|
|
23292
|
+
914: "所属C端账号密码被修改,请重新登录",
|
|
23293
|
+
903: "账户已登出,需重新登陆重试!",
|
|
23294
|
+
902: "登录已过期,请重新登录!",
|
|
23295
|
+
906: "账号存在风险,请重新登录!",
|
|
23296
|
+
"-9136": "因违反社区规范禁止发笔记,请检查账号状态!"
|
|
23297
|
+
};
|
|
23298
|
+
const mock_xsEncrypt = new xhs_ob_feed_Xhshow();
|
|
23299
|
+
const xiaohongshuPublish_mock_mockAction = async (task, params)=>{
|
|
23300
|
+
const tmpCachePath = task.getTmpPath();
|
|
23301
|
+
if (params?.selfDeclaration?.type === "source-statement" && "transshipment" === params.selfDeclaration.childType && params.originalBind) return {
|
|
23256
23302
|
code: 414,
|
|
23257
|
-
|
|
23258
|
-
|
|
23259
|
-
});
|
|
23260
|
-
const xiaohongshuWebCommentAction_xsEncrypt = new Xhshow();
|
|
23261
|
-
const xiaohongshuWebCommentAction = async (_task, params)=>{
|
|
23262
|
-
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "点赞相关操作失败", {});
|
|
23263
|
-
const headers = {
|
|
23264
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
23265
|
-
referer: "https://www.xiaohongshu.com/",
|
|
23266
|
-
origin: "https://www.xiaohongshu.com/"
|
|
23303
|
+
message: "原创声明与转载声明互斥,请重新选择后发布!",
|
|
23304
|
+
data: ""
|
|
23267
23305
|
};
|
|
23268
|
-
const args = [
|
|
23269
|
-
{
|
|
23270
|
-
headers
|
|
23271
|
-
},
|
|
23272
|
-
_task.logger,
|
|
23273
|
-
params.proxyLoc,
|
|
23274
|
-
params.localIP,
|
|
23275
|
-
params.accountId
|
|
23276
|
-
];
|
|
23277
|
-
const http = new Http(...args);
|
|
23278
23306
|
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
23279
23307
|
if (!a1Cookie) return {
|
|
23280
23308
|
code: 414,
|
|
23281
23309
|
message: "账号数据异常,请重新绑定账号后重试。",
|
|
23282
|
-
data:
|
|
23283
|
-
};
|
|
23284
|
-
if (!params.note_id && !params.comment_id && !params.action) return {
|
|
23285
|
-
code: 414,
|
|
23286
|
-
message: "参数缺失,请检查后重试!",
|
|
23287
|
-
data: {}
|
|
23288
|
-
};
|
|
23289
|
-
const actionParams = {
|
|
23290
|
-
note_id: params.note_id,
|
|
23291
|
-
comment_id: params.comment_id
|
|
23310
|
+
data: ""
|
|
23292
23311
|
};
|
|
23293
|
-
|
|
23294
|
-
|
|
23295
|
-
|
|
23296
|
-
|
|
23312
|
+
const headers = {
|
|
23313
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
23314
|
+
origin: "https://creator.xiaohongshu.com",
|
|
23315
|
+
referer: "https://creator.xiaohongshu.com/",
|
|
23316
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
|
|
23297
23317
|
};
|
|
23298
23318
|
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
23299
23319
|
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
23300
23320
|
return acc;
|
|
23301
23321
|
}, {});
|
|
23302
|
-
switch(params.action){
|
|
23303
|
-
case "like":
|
|
23304
|
-
{
|
|
23305
|
-
const likeAction = "/api/sns/web/v1/comment/like";
|
|
23306
|
-
const likeActionXsHeader = xiaohongshuWebCommentAction_xsEncrypt.signHeadersPost(likeAction, recordCookie, "xhs-pc-web", actionParams);
|
|
23307
|
-
likeActionRes = await http.api({
|
|
23308
|
-
method: "post",
|
|
23309
|
-
url: "https://edith.xiaohongshu.com/api/sns/web/v1/comment/like",
|
|
23310
|
-
data: actionParams,
|
|
23311
|
-
headers: likeActionXsHeader
|
|
23312
|
-
}, {
|
|
23313
|
-
retries: 3,
|
|
23314
|
-
retryDelay: 20,
|
|
23315
|
-
timeout: 3000
|
|
23316
|
-
});
|
|
23317
|
-
break;
|
|
23318
|
-
}
|
|
23319
|
-
case "dislike":
|
|
23320
|
-
{
|
|
23321
|
-
const dislikeMentions = "/api/sns/web/v1/comment/dislike";
|
|
23322
|
-
const dislikeXsHeader = xiaohongshuWebCommentAction_xsEncrypt.signHeadersPost(dislikeMentions, recordCookie, "xhs-pc-web", actionParams);
|
|
23323
|
-
likeActionRes = await http.api({
|
|
23324
|
-
method: "post",
|
|
23325
|
-
url: "https://edith.xiaohongshu.com/api/sns/web/v1/comment/dislike",
|
|
23326
|
-
data: actionParams,
|
|
23327
|
-
headers: dislikeXsHeader
|
|
23328
|
-
}, {
|
|
23329
|
-
retries: 3,
|
|
23330
|
-
retryDelay: 20,
|
|
23331
|
-
timeout: 3000
|
|
23332
|
-
});
|
|
23333
|
-
break;
|
|
23334
|
-
}
|
|
23335
|
-
default:
|
|
23336
|
-
return {
|
|
23337
|
-
code: 414,
|
|
23338
|
-
message: "参数action错误,请重试!",
|
|
23339
|
-
data: {}
|
|
23340
|
-
};
|
|
23341
|
-
}
|
|
23342
|
-
const isSuccess = 0 === likeActionRes.code;
|
|
23343
|
-
const message = `点赞相关操作${isSuccess ? "成功" : `失败,原因:${likeActionRes.msg}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
23344
|
-
const data = isSuccess ? likeActionRes.success : {};
|
|
23345
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
23346
|
-
};
|
|
23347
|
-
const xiaohongshuWebIntimacySearch = async (_task, params)=>{
|
|
23348
|
-
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, "搜索@列表数据成功", []);
|
|
23349
|
-
const headers = {
|
|
23350
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
23351
|
-
referer: "https://www.xiaohongshu.com/",
|
|
23352
|
-
origin: "https://www.xiaohongshu.com"
|
|
23353
|
-
};
|
|
23354
23322
|
const args = [
|
|
23355
23323
|
{
|
|
23356
23324
|
headers
|
|
23357
23325
|
},
|
|
23358
|
-
|
|
23326
|
+
task.logger,
|
|
23359
23327
|
params.proxyLoc,
|
|
23360
23328
|
params.localIP,
|
|
23361
23329
|
params.accountId
|
|
23362
23330
|
];
|
|
23363
|
-
const http = new Http(
|
|
23364
|
-
|
|
23365
|
-
const res = await http.api({
|
|
23366
|
-
method: "get",
|
|
23367
|
-
url: `https://edith.xiaohongshu.com/api/sns/web/v1/intimacy/intimacy_list${params.searchValue ? "/search" : ""}`,
|
|
23368
|
-
...params.searchValue ? {
|
|
23369
|
-
params: {
|
|
23370
|
-
keyword: params.searchValue,
|
|
23371
|
-
page: 1,
|
|
23372
|
-
rows: 30
|
|
23373
|
-
}
|
|
23374
|
-
} : {}
|
|
23375
|
-
}, {
|
|
23376
|
-
retries: 3,
|
|
23377
|
-
retryDelay: 20,
|
|
23378
|
-
timeout: 3000
|
|
23331
|
+
const http = new Http({
|
|
23332
|
+
headers
|
|
23379
23333
|
});
|
|
23380
|
-
const
|
|
23381
|
-
|
|
23382
|
-
|
|
23383
|
-
|
|
23384
|
-
|
|
23385
|
-
|
|
23386
|
-
|
|
23387
|
-
|
|
23388
|
-
|
|
23389
|
-
|
|
23390
|
-
|
|
23391
|
-
|
|
23334
|
+
const proxyHttp = new Http(...args);
|
|
23335
|
+
proxyHttp.addResponseInterceptor((response)=>{
|
|
23336
|
+
const responseData = response.data;
|
|
23337
|
+
if (response && responseData?.code && 0 !== responseData.code || responseData?.code && !responseData.success) {
|
|
23338
|
+
const errmsg = xiaohongshuPublish_mock_errnoMap[responseData.code] || response.config.defaultErrorMsg || "文章发布异常,请稍后重试。";
|
|
23339
|
+
return {
|
|
23340
|
+
code: xiaohongshuPublish_mock_errnoMap[responseData.code] ? 414 : 500,
|
|
23341
|
+
message: errmsg,
|
|
23342
|
+
data: responseData
|
|
23343
|
+
};
|
|
23344
|
+
}
|
|
23345
|
+
});
|
|
23346
|
+
const fetchCoverUrl = "/api/media/v1/upload/creator/permit";
|
|
23347
|
+
const fetchCoverParams = {
|
|
23348
|
+
biz_name: "spectrum",
|
|
23349
|
+
scene: "image",
|
|
23350
|
+
file_count: params.banners.length,
|
|
23351
|
+
version: 1,
|
|
23352
|
+
source: "web"
|
|
23392
23353
|
};
|
|
23393
|
-
const
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
|
|
23397
|
-
|
|
23398
|
-
|
|
23399
|
-
|
|
23400
|
-
|
|
23401
|
-
|
|
23402
|
-
|
|
23403
|
-
|
|
23404
|
-
|
|
23354
|
+
const fetchCoverXsHeader = mock_xsEncrypt.signHeadersGet(fetchCoverUrl, recordCookie, "ugc", fetchCoverParams);
|
|
23355
|
+
const uploadInfos = [];
|
|
23356
|
+
if (params.banners.length > 18) {
|
|
23357
|
+
const num = Math.ceil(params.banners.length / 14);
|
|
23358
|
+
for(let i = 0; i < num; i++){
|
|
23359
|
+
const start = 14 * i;
|
|
23360
|
+
params.banners.length;
|
|
23361
|
+
({
|
|
23362
|
+
...fetchCoverParams
|
|
23363
|
+
});
|
|
23364
|
+
const batchCoverIdInfo = await proxyHttp.api({
|
|
23365
|
+
method: "get",
|
|
23366
|
+
baseURL: "https://creator.xiaohongshu.com",
|
|
23367
|
+
url: fetchCoverUrl,
|
|
23368
|
+
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
23369
|
+
headers: fetchCoverXsHeader,
|
|
23370
|
+
params: fetchCoverParams
|
|
23371
|
+
}, {
|
|
23372
|
+
retries: 3,
|
|
23373
|
+
retryDelay: 20,
|
|
23374
|
+
timeout: 3000
|
|
23375
|
+
});
|
|
23376
|
+
for (const item of batchCoverIdInfo.data.uploadTempPermits)for (const fileId of item.fileIds)uploadInfos.push({
|
|
23377
|
+
bucket: item.bucket || "",
|
|
23378
|
+
uploadAddr: item.uploadAddr || "",
|
|
23379
|
+
fileIds: fileId,
|
|
23380
|
+
token: item.token || ""
|
|
23381
|
+
});
|
|
23382
|
+
}
|
|
23383
|
+
} else {
|
|
23384
|
+
const coverIdInfo = await proxyHttp.api({
|
|
23385
|
+
method: "get",
|
|
23386
|
+
baseURL: "https://creator.xiaohongshu.com",
|
|
23387
|
+
url: fetchCoverUrl,
|
|
23388
|
+
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
23389
|
+
headers: fetchCoverXsHeader,
|
|
23390
|
+
params: fetchCoverParams
|
|
23391
|
+
}, {
|
|
23392
|
+
retries: 3,
|
|
23393
|
+
retryDelay: 20,
|
|
23394
|
+
timeout: 3000
|
|
23395
|
+
});
|
|
23396
|
+
for (const item of coverIdInfo.data.uploadTempPermits)for (const fileId of item.fileIds)uploadInfos.push({
|
|
23397
|
+
bucket: item.bucket || "",
|
|
23398
|
+
uploadAddr: item.uploadAddr || "",
|
|
23399
|
+
fileIds: fileId,
|
|
23400
|
+
token: item.token || ""
|
|
23401
|
+
});
|
|
23402
|
+
}
|
|
23403
|
+
if (uploadInfos.length < params.banners.length) return {
|
|
23405
23404
|
code: 414,
|
|
23406
|
-
message: "
|
|
23407
|
-
data:
|
|
23405
|
+
message: "可用 OSS bucket 数量不足,无法上传所有图片!",
|
|
23406
|
+
data: ""
|
|
23408
23407
|
};
|
|
23409
|
-
if (
|
|
23408
|
+
if (0 === uploadInfos.length) return {
|
|
23410
23409
|
code: 414,
|
|
23411
|
-
message: "
|
|
23412
|
-
data:
|
|
23413
|
-
};
|
|
23414
|
-
const replyParams = {
|
|
23415
|
-
type: params.type
|
|
23416
|
-
};
|
|
23417
|
-
const fatchMentions = "/api/sns/web/v1/message/read";
|
|
23418
|
-
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
23419
|
-
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
23420
|
-
return acc;
|
|
23421
|
-
}, {});
|
|
23422
|
-
const fatchMentionsXsHeader = xiaohongshuWebMsgRead_xsEncrypt.signHeadersPost(fatchMentions, recordCookie, "xhs-pc-web", replyParams);
|
|
23423
|
-
const res = await http.api({
|
|
23424
|
-
method: "post",
|
|
23425
|
-
url: "https://edith.xiaohongshu.com/api/sns/web/v1/message/read",
|
|
23426
|
-
data: replyParams,
|
|
23427
|
-
headers: fatchMentionsXsHeader
|
|
23428
|
-
}, {
|
|
23429
|
-
retries: 3,
|
|
23430
|
-
retryDelay: 20,
|
|
23431
|
-
timeout: 3000
|
|
23432
|
-
});
|
|
23433
|
-
const isSuccess = 0 === res.code;
|
|
23434
|
-
const message = `Read指定Tab${isSuccess ? "成功" : `失败,原因:${res.msg}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
23435
|
-
const data = isSuccess ? res.success : {};
|
|
23436
|
-
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
23437
|
-
};
|
|
23438
|
-
const xiaohongshuWebMsgReply_xsEncrypt = new Xhshow();
|
|
23439
|
-
const xiaohongshuWebMsgReply = async (_task, params)=>{
|
|
23440
|
-
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "评论回复失败", {});
|
|
23441
|
-
const headers = {
|
|
23442
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
23443
|
-
referer: "https://www.xiaohongshu.com/",
|
|
23444
|
-
origin: "https://www.xiaohongshu.com/"
|
|
23410
|
+
message: "图片上传失败,请稍后重试!",
|
|
23411
|
+
data: ""
|
|
23445
23412
|
};
|
|
23446
|
-
const
|
|
23447
|
-
|
|
23448
|
-
|
|
23449
|
-
|
|
23450
|
-
|
|
23451
|
-
|
|
23452
|
-
|
|
23453
|
-
|
|
23454
|
-
|
|
23455
|
-
|
|
23456
|
-
|
|
23457
|
-
|
|
23458
|
-
|
|
23459
|
-
|
|
23460
|
-
|
|
23413
|
+
const availableBuckets = Array.from({
|
|
23414
|
+
length: uploadInfos.length
|
|
23415
|
+
}, (_, i)=>i);
|
|
23416
|
+
const uploadFile = async (url, index)=>{
|
|
23417
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
23418
|
+
const localUrl = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
23419
|
+
const fileBuffer = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(localUrl);
|
|
23420
|
+
const MAX_RETRIES = uploadInfos.length;
|
|
23421
|
+
let attempt = 0;
|
|
23422
|
+
while(attempt < MAX_RETRIES){
|
|
23423
|
+
const ossBucketIndex = availableBuckets.shift();
|
|
23424
|
+
if (void 0 === ossBucketIndex) break;
|
|
23425
|
+
const currentInfo = uploadInfos[ossBucketIndex];
|
|
23426
|
+
const ossFileId = currentInfo.fileIds;
|
|
23427
|
+
const ossToken = currentInfo.token;
|
|
23428
|
+
const ossDomain = currentInfo.uploadAddr;
|
|
23429
|
+
try {
|
|
23430
|
+
await http.api({
|
|
23431
|
+
method: "put",
|
|
23432
|
+
url: `https://${ossDomain}/${ossFileId}`,
|
|
23433
|
+
data: fileBuffer,
|
|
23434
|
+
headers: {
|
|
23435
|
+
"x-cos-security-token": ossToken
|
|
23436
|
+
},
|
|
23437
|
+
defaultErrorMsg: "图片上传异常,请稍后重试发布。"
|
|
23438
|
+
});
|
|
23439
|
+
return {
|
|
23440
|
+
ossFileId,
|
|
23441
|
+
ossToken
|
|
23442
|
+
};
|
|
23443
|
+
} catch (error) {
|
|
23444
|
+
attempt++;
|
|
23445
|
+
}
|
|
23446
|
+
}
|
|
23447
|
+
return {
|
|
23448
|
+
ossFileId: "",
|
|
23449
|
+
ossToken: ""
|
|
23450
|
+
};
|
|
23461
23451
|
};
|
|
23462
|
-
|
|
23452
|
+
const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
|
|
23453
|
+
const invalidUpload = coverInfos.find((it)=>"" === it.ossToken || "" === it.ossFileId);
|
|
23454
|
+
if (invalidUpload) return {
|
|
23463
23455
|
code: 414,
|
|
23464
|
-
message: "
|
|
23465
|
-
data:
|
|
23456
|
+
message: "图片上传异常,请稍后重试发布。",
|
|
23457
|
+
data: ""
|
|
23466
23458
|
};
|
|
23467
|
-
|
|
23468
|
-
|
|
23469
|
-
|
|
23470
|
-
|
|
23471
|
-
|
|
23459
|
+
if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
|
|
23460
|
+
if (!topic.id) {
|
|
23461
|
+
const topicData = {
|
|
23462
|
+
topic_names: topic.name
|
|
23463
|
+
};
|
|
23464
|
+
const topicXsHeader = mock_xsEncrypt.signHeadersPost("/web_api/sns/capa/postgw/topic/batch_customized", recordCookie, "ugc", topicData);
|
|
23465
|
+
const createTopic = await proxyHttp.api({
|
|
23466
|
+
method: "POST",
|
|
23467
|
+
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
23468
|
+
headers: topicXsHeader,
|
|
23469
|
+
data: topicData,
|
|
23470
|
+
defaultErrorMsg: "话题创建异常,请稍后重试。"
|
|
23471
|
+
}, {
|
|
23472
|
+
retries: 3,
|
|
23473
|
+
retryDelay: 20,
|
|
23474
|
+
timeout: 3000
|
|
23475
|
+
});
|
|
23476
|
+
if (!createTopic?.data) throw types_errorResponse("话题创建失败,请检查话题字段!", 414);
|
|
23477
|
+
Object.assign(topic, createTopic?.data?.topic_infos[0]);
|
|
23478
|
+
}
|
|
23479
|
+
}));
|
|
23480
|
+
const visibleRangeMap = {
|
|
23481
|
+
public: 0,
|
|
23482
|
+
private: 1,
|
|
23483
|
+
friends: 4
|
|
23472
23484
|
};
|
|
23473
|
-
const
|
|
23474
|
-
|
|
23475
|
-
|
|
23476
|
-
|
|
23477
|
-
|
|
23478
|
-
|
|
23479
|
-
|
|
23480
|
-
|
|
23481
|
-
|
|
23482
|
-
|
|
23483
|
-
|
|
23484
|
-
|
|
23485
|
-
|
|
23486
|
-
|
|
23487
|
-
|
|
23488
|
-
|
|
23489
|
-
|
|
23490
|
-
|
|
23491
|
-
|
|
23492
|
-
|
|
23493
|
-
|
|
23494
|
-
|
|
23495
|
-
|
|
23496
|
-
|
|
23497
|
-
|
|
23498
|
-
|
|
23499
|
-
};
|
|
23500
|
-
if ("undefined" != typeof process) {
|
|
23501
|
-
process.on("uncaughtException", ()=>{});
|
|
23502
|
-
process.on("unhandledRejection", ()=>{});
|
|
23503
|
-
}
|
|
23504
|
-
const mnsv2_enc = (arg1, arg2, cookieString)=>{
|
|
23505
|
-
const win = getWindow();
|
|
23506
|
-
win.ck = cookieString;
|
|
23507
|
-
__webpack_require__("./src/utils/xhs_ob_feed/ob.env.js");
|
|
23508
|
-
try {
|
|
23509
|
-
__webpack_require__("./src/utils/xhs_ob_feed/ob.enc.js");
|
|
23510
|
-
} catch {}
|
|
23511
|
-
let result = "";
|
|
23512
|
-
try {
|
|
23513
|
-
result = win.mnsv2(arg1, arg2);
|
|
23514
|
-
} catch {}
|
|
23515
|
-
return result;
|
|
23516
|
-
};
|
|
23517
|
-
const mnsvc2 = mnsv2_enc;
|
|
23518
|
-
const xhs_ob_feed_encode_mnsv2 = __webpack_require__("./src/utils/xhs_ob_feed/x_s.encoder.js");
|
|
23519
|
-
class xhs_ob_feed_Xhshow {
|
|
23520
|
-
stringifyCookies(cookies) {
|
|
23521
|
-
return Object.entries(cookies).map(([key, value])=>`${key}=${value}`).join("; ");
|
|
23522
|
-
}
|
|
23523
|
-
signHeadersGet(uri, cookieString, xsecAppid = "ugc", params) {
|
|
23524
|
-
let para1 = "";
|
|
23525
|
-
if (params && 0 !== Object.keys(params).length) {
|
|
23526
|
-
const _queryPara = Object.entries(params).map(([key, value])=>{
|
|
23527
|
-
let valueStr = "";
|
|
23528
|
-
if (Array.isArray(value)) valueStr = value.map((v)=>String(v)).join(",");
|
|
23529
|
-
else if (null != value) valueStr = String(value);
|
|
23530
|
-
return `${key}=${valueStr}`;
|
|
23531
|
-
});
|
|
23532
|
-
para1 = `${uri}?${_queryPara.join("&")}`;
|
|
23533
|
-
} else para1 = uri;
|
|
23534
|
-
const md5Para1 = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(para1).digest("hex");
|
|
23535
|
-
const mnsvc2_data = mnsvc2(para1, md5Para1, this.stringifyCookies(cookieString));
|
|
23536
|
-
return {
|
|
23537
|
-
"X-S": xhs_ob_feed_encode_mnsv2(mnsvc2_data, xsecAppid, "Windows", "object")
|
|
23538
|
-
};
|
|
23539
|
-
}
|
|
23540
|
-
signHeadersPost(uri, cookieString, xsecAppid = "ugc", payload) {
|
|
23541
|
-
const para1 = uri + JSON.stringify(payload || {});
|
|
23542
|
-
const md5Para1 = __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(para1).digest("hex");
|
|
23543
|
-
const mnsvc2_data = mnsvc2(para1, md5Para1, this.stringifyCookies(cookieString));
|
|
23544
|
-
return {
|
|
23545
|
-
"X-S": xhs_ob_feed_encode_mnsv2(mnsvc2_data, xsecAppid, "Windows", "object")
|
|
23546
|
-
};
|
|
23547
|
-
}
|
|
23548
|
-
}
|
|
23549
|
-
const xiaohongshuWebNoteFeed_xsEncrypt = new xhs_ob_feed_Xhshow();
|
|
23550
|
-
const GenXSCommon = __webpack_require__("./src/utils/XhsXsCommonEnc.js");
|
|
23551
|
-
const xiaohongshuWebNoteFeed = async (_task, params)=>{
|
|
23552
|
-
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "获取指定文章详情失败", {});
|
|
23553
|
-
const headers = {
|
|
23554
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
23555
|
-
referer: "https://www.xiaohongshu.com/",
|
|
23556
|
-
origin: "https://www.xiaohongshu.com/"
|
|
23557
|
-
};
|
|
23558
|
-
const args = [
|
|
23559
|
-
{
|
|
23560
|
-
headers
|
|
23485
|
+
const publishData = {
|
|
23486
|
+
common: {
|
|
23487
|
+
ats: [],
|
|
23488
|
+
biz_relations: [],
|
|
23489
|
+
desc: params?.content,
|
|
23490
|
+
goods_info: {},
|
|
23491
|
+
hash_tag: params.topic || [],
|
|
23492
|
+
note_id: "",
|
|
23493
|
+
source: JSON.stringify({
|
|
23494
|
+
type: "web",
|
|
23495
|
+
ids: "",
|
|
23496
|
+
extraInfo: '{"systemId":"web"}'
|
|
23497
|
+
}),
|
|
23498
|
+
title: params?.title,
|
|
23499
|
+
type: "normal",
|
|
23500
|
+
privacy_info: {
|
|
23501
|
+
op_type: 1,
|
|
23502
|
+
type: visibleRangeMap[params.visibleRange]
|
|
23503
|
+
},
|
|
23504
|
+
post_loc: params.address ? {
|
|
23505
|
+
name: params.address?.name,
|
|
23506
|
+
poi_id: params.address?.poi_id,
|
|
23507
|
+
poi_type: params.address?.poi_type,
|
|
23508
|
+
subname: params.address?.full_address
|
|
23509
|
+
} : null,
|
|
23510
|
+
business_binds: ""
|
|
23561
23511
|
},
|
|
23562
|
-
|
|
23563
|
-
|
|
23564
|
-
|
|
23565
|
-
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23569
|
-
|
|
23570
|
-
|
|
23571
|
-
|
|
23572
|
-
|
|
23573
|
-
|
|
23574
|
-
if (!params.source_note_id && !params.xsec_token) return {
|
|
23575
|
-
code: 414,
|
|
23576
|
-
message: "参数缺失,请检查后重试!",
|
|
23577
|
-
data: {}
|
|
23578
|
-
};
|
|
23579
|
-
const feedParams = {
|
|
23580
|
-
source_note_id: params.source_note_id,
|
|
23581
|
-
image_formats: [
|
|
23582
|
-
"jpg",
|
|
23583
|
-
"webp",
|
|
23584
|
-
"avif"
|
|
23585
|
-
],
|
|
23586
|
-
extra: {
|
|
23587
|
-
need_body_topic: "1"
|
|
23512
|
+
image_info: {
|
|
23513
|
+
images: coverInfos.map((it)=>({
|
|
23514
|
+
extra_info_json: '{"mimeType":"image/png"}',
|
|
23515
|
+
file_id: it.ossFileId,
|
|
23516
|
+
metadata: {
|
|
23517
|
+
source: -1
|
|
23518
|
+
},
|
|
23519
|
+
stickers: {
|
|
23520
|
+
floating: [],
|
|
23521
|
+
version: 2
|
|
23522
|
+
}
|
|
23523
|
+
}))
|
|
23588
23524
|
},
|
|
23589
|
-
|
|
23590
|
-
xsec_token: params.xsec_token
|
|
23525
|
+
video_info: null
|
|
23591
23526
|
};
|
|
23592
|
-
const
|
|
23593
|
-
|
|
23594
|
-
|
|
23595
|
-
|
|
23596
|
-
}
|
|
23597
|
-
|
|
23598
|
-
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
|
|
23602
|
-
|
|
23603
|
-
|
|
23604
|
-
|
|
23605
|
-
|
|
23606
|
-
|
|
23607
|
-
|
|
23608
|
-
|
|
23609
|
-
|
|
23610
|
-
|
|
23527
|
+
const userDeclarationBind = {
|
|
23528
|
+
origin: 2,
|
|
23529
|
+
photoInfo: {},
|
|
23530
|
+
repostInfo: {}
|
|
23531
|
+
};
|
|
23532
|
+
if (params.selfDeclaration?.type === "fictional-rendition") userDeclarationBind.origin = 1;
|
|
23533
|
+
else if (params.selfDeclaration?.type === "ai-generated") userDeclarationBind.origin = 2;
|
|
23534
|
+
else if (params.selfDeclaration?.type === "source-statement") {
|
|
23535
|
+
if ("self-labeling" === params.selfDeclaration.childType) userDeclarationBind.origin = 3;
|
|
23536
|
+
else if ("self-shooting" === params.selfDeclaration.childType) {
|
|
23537
|
+
userDeclarationBind.origin = 4;
|
|
23538
|
+
const photoInfo = {};
|
|
23539
|
+
if (params.selfDeclaration.shootingLocation) photoInfo.photoPlace = {
|
|
23540
|
+
name: params.selfDeclaration.shootingLocation.name,
|
|
23541
|
+
poiId: params.selfDeclaration.shootingLocation.poi_id,
|
|
23542
|
+
poiType: params.selfDeclaration.shootingLocation.poi_type,
|
|
23543
|
+
subname: params.selfDeclaration.shootingLocation.full_address
|
|
23544
|
+
};
|
|
23545
|
+
if (params.selfDeclaration.shootingDate) photoInfo.photoTime = params.selfDeclaration.shootingDate;
|
|
23546
|
+
userDeclarationBind.photoInfo = photoInfo;
|
|
23547
|
+
} else if ("transshipment" === params.selfDeclaration.childType) {
|
|
23548
|
+
userDeclarationBind.origin = 5;
|
|
23549
|
+
if (params.selfDeclaration.sourceMedia) userDeclarationBind.repostInfo = {
|
|
23550
|
+
source: params.selfDeclaration.sourceMedia
|
|
23551
|
+
};
|
|
23611
23552
|
}
|
|
23553
|
+
}
|
|
23554
|
+
const bizId = params?.originalBind && (params.cookies.find((it)=>"x-user-id-creator.xiaohongshu.com" === it.name)?.value || await proxyHttp.api({
|
|
23555
|
+
method: "get",
|
|
23556
|
+
url: "https://creator.xiaohongshu.com/api/galaxy/user/my-info"
|
|
23612
23557
|
}, {
|
|
23613
23558
|
retries: 3,
|
|
23614
23559
|
retryDelay: 20,
|
|
23615
23560
|
timeout: 3000
|
|
23616
|
-
});
|
|
23617
|
-
|
|
23618
|
-
|
|
23619
|
-
|
|
23620
|
-
|
|
23621
|
-
|
|
23622
|
-
}
|
|
23623
|
-
|
|
23624
|
-
const xiaohongshuWebRelationAction = async (_task, params)=>{
|
|
23625
|
-
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "用户关系操作失败", {});
|
|
23626
|
-
const headers = {
|
|
23627
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
23628
|
-
referer: "https://www.xiaohongshu.com/",
|
|
23629
|
-
origin: "https://www.xiaohongshu.com/"
|
|
23630
|
-
};
|
|
23631
|
-
const args = [
|
|
23632
|
-
{
|
|
23633
|
-
headers
|
|
23561
|
+
}).then((userData)=>userData.data?.userDetail?.id));
|
|
23562
|
+
const business_binds = {
|
|
23563
|
+
version: 1,
|
|
23564
|
+
bizType: "",
|
|
23565
|
+
noteId: "",
|
|
23566
|
+
noteOrderBind: {},
|
|
23567
|
+
notePostTiming: params.isImmediatelyPublish ? {} : {
|
|
23568
|
+
postTime: params.scheduledPublish
|
|
23634
23569
|
},
|
|
23635
|
-
|
|
23636
|
-
|
|
23637
|
-
|
|
23638
|
-
|
|
23639
|
-
|
|
23640
|
-
|
|
23641
|
-
|
|
23642
|
-
if (!a1Cookie) return {
|
|
23643
|
-
code: 414,
|
|
23644
|
-
message: "账号数据异常,请重新绑定账号后重试。",
|
|
23645
|
-
data: {}
|
|
23646
|
-
};
|
|
23647
|
-
if (!params.action || !params.target_user_id) return {
|
|
23648
|
-
code: 414,
|
|
23649
|
-
message: "参数缺失,请检查后重试!",
|
|
23650
|
-
data: {}
|
|
23651
|
-
};
|
|
23652
|
-
const relationParams = {
|
|
23653
|
-
target_user_id: params.target_user_id
|
|
23654
|
-
};
|
|
23655
|
-
let relationActionRes;
|
|
23656
|
-
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
23657
|
-
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
23658
|
-
return acc;
|
|
23659
|
-
}, {});
|
|
23660
|
-
switch(params.action){
|
|
23661
|
-
case "follow":
|
|
23570
|
+
coProduceBind: {
|
|
23571
|
+
enable: !!params?.coProduceBind
|
|
23572
|
+
},
|
|
23573
|
+
noteCopyBind: {
|
|
23574
|
+
copyable: !!params?.noteCopyBind
|
|
23575
|
+
},
|
|
23576
|
+
optionRelationList: params.originalBind ? [
|
|
23662
23577
|
{
|
|
23663
|
-
|
|
23664
|
-
|
|
23665
|
-
|
|
23666
|
-
|
|
23667
|
-
|
|
23668
|
-
|
|
23669
|
-
|
|
23670
|
-
|
|
23671
|
-
retries: 3,
|
|
23672
|
-
retryDelay: 500,
|
|
23673
|
-
timeout: 3000
|
|
23674
|
-
});
|
|
23675
|
-
break;
|
|
23578
|
+
type: "ORIGINAL_STATEMENT",
|
|
23579
|
+
relationList: [
|
|
23580
|
+
{
|
|
23581
|
+
bizId,
|
|
23582
|
+
bizType: "ORIGINAL_STATEMENT",
|
|
23583
|
+
extraInfo: "{}"
|
|
23584
|
+
}
|
|
23585
|
+
]
|
|
23676
23586
|
}
|
|
23677
|
-
|
|
23678
|
-
|
|
23679
|
-
|
|
23680
|
-
|
|
23681
|
-
|
|
23682
|
-
|
|
23683
|
-
|
|
23684
|
-
data: relationParams,
|
|
23685
|
-
headers: unfllowXsHeader
|
|
23686
|
-
}, {
|
|
23687
|
-
retries: 3,
|
|
23688
|
-
retryDelay: 20,
|
|
23689
|
-
timeout: 3000
|
|
23690
|
-
});
|
|
23691
|
-
break;
|
|
23587
|
+
] : [],
|
|
23588
|
+
...params?.groupBind ? {
|
|
23589
|
+
groupBind: {
|
|
23590
|
+
groupId: params?.groupBind?.group_id,
|
|
23591
|
+
groupName: params.groupBind?.group_name,
|
|
23592
|
+
desc: params.groupBind?.desc,
|
|
23593
|
+
avatar: params.groupBind?.avatar
|
|
23692
23594
|
}
|
|
23693
|
-
|
|
23694
|
-
|
|
23695
|
-
|
|
23696
|
-
|
|
23697
|
-
|
|
23698
|
-
|
|
23699
|
-
|
|
23700
|
-
|
|
23701
|
-
|
|
23702
|
-
|
|
23703
|
-
|
|
23595
|
+
} : {
|
|
23596
|
+
groupBind: {}
|
|
23597
|
+
},
|
|
23598
|
+
...params.selfDeclaration ? {
|
|
23599
|
+
userDeclarationBind
|
|
23600
|
+
} : {},
|
|
23601
|
+
...params?.collectionBind?.id ? {
|
|
23602
|
+
noteCollectionBind: {
|
|
23603
|
+
id: params.collectionBind.id
|
|
23604
|
+
}
|
|
23605
|
+
} : {}
|
|
23704
23606
|
};
|
|
23607
|
+
publishData.common.business_binds = JSON.stringify(business_binds);
|
|
23608
|
+
const publishXsHeader = mock_xsEncrypt.signHeadersPost("/web_api/sns/v2/note", recordCookie, "ugc", publishData);
|
|
23609
|
+
task._timerRecord.PrePublish = Date.now();
|
|
23610
|
+
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
23611
|
+
if (MockPublish) {
|
|
23612
|
+
const message = `文章模拟发布成功 ${http.proxyInfo}`;
|
|
23613
|
+
const data = "123456789";
|
|
23614
|
+
await updateTaskState?.({
|
|
23615
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
23616
|
+
result: {
|
|
23617
|
+
response: data
|
|
23618
|
+
}
|
|
23619
|
+
});
|
|
23620
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(data, message);
|
|
23621
|
+
}
|
|
23622
|
+
const publishResult = await proxyHttp.api({
|
|
23623
|
+
method: "post",
|
|
23624
|
+
url: "https://edith.xiaohongshu.com/web_api/sns/v2/note",
|
|
23625
|
+
data: publishData,
|
|
23626
|
+
headers: publishXsHeader,
|
|
23627
|
+
defaultErrorMsg: "文章发布异常,请稍后重试。"
|
|
23628
|
+
}, {
|
|
23629
|
+
retries: 2,
|
|
23630
|
+
retryDelay: 500,
|
|
23631
|
+
timeout: 12000
|
|
23632
|
+
});
|
|
23633
|
+
reportLogger({
|
|
23634
|
+
token: params.huiwenToken || "",
|
|
23635
|
+
enverionment: task.enverionment || "development",
|
|
23636
|
+
postId: params.articleId,
|
|
23637
|
+
eip: proxyHttp.proxyInfo,
|
|
23638
|
+
proxyIp: params.localIP,
|
|
23639
|
+
accountId: params.accountId,
|
|
23640
|
+
uid: params.uid,
|
|
23641
|
+
platform: "xiaohongshu",
|
|
23642
|
+
publishParams: publishData
|
|
23643
|
+
});
|
|
23644
|
+
const isSuccess = publishResult.success;
|
|
23645
|
+
const message = `文章发布${isSuccess ? "成功" : `失败,原因:${publishResult.msg}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
23646
|
+
const data = isSuccess ? publishResult.data?.id || "" : "";
|
|
23647
|
+
if (!isSuccess) {
|
|
23648
|
+
await updateTaskState?.({
|
|
23649
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
23650
|
+
error: message
|
|
23651
|
+
});
|
|
23652
|
+
return {
|
|
23653
|
+
code: 414,
|
|
23654
|
+
data,
|
|
23655
|
+
message
|
|
23656
|
+
};
|
|
23657
|
+
}
|
|
23658
|
+
await updateTaskState?.({
|
|
23659
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
23660
|
+
result: {
|
|
23661
|
+
response: data
|
|
23662
|
+
}
|
|
23663
|
+
});
|
|
23705
23664
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
23706
23665
|
};
|
|
23707
|
-
const
|
|
23708
|
-
const
|
|
23709
|
-
|
|
23710
|
-
|
|
23711
|
-
|
|
23712
|
-
|
|
23713
|
-
"
|
|
23714
|
-
"
|
|
23715
|
-
|
|
23716
|
-
]),
|
|
23717
|
-
time_filter: schemas_enum([
|
|
23718
|
-
"不限",
|
|
23719
|
-
"一周内"
|
|
23720
|
-
])
|
|
23721
|
-
});
|
|
23722
|
-
const createSearchId = ()=>{
|
|
23723
|
-
let r = BigInt(Date.now());
|
|
23724
|
-
const o = BigInt(Math.ceil(0x7ffffffe * Math.random()));
|
|
23725
|
-
r <<= BigInt(64);
|
|
23726
|
-
r += o;
|
|
23727
|
-
return r.toString(36);
|
|
23728
|
-
};
|
|
23729
|
-
const xiaohongshuWebSearch = async (_task, params)=>{
|
|
23730
|
-
const headers = {
|
|
23731
|
-
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
23732
|
-
referer: "https://www.xiaohongshu.com/",
|
|
23733
|
-
origin: "https://www.xiaohongshu.com/"
|
|
23666
|
+
const xiaohongshuPublish_rpa_rpaAction = async (task, params)=>{
|
|
23667
|
+
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
23668
|
+
const commonCookies = {
|
|
23669
|
+
path: "/",
|
|
23670
|
+
sameSite: "lax",
|
|
23671
|
+
secure: false,
|
|
23672
|
+
domain: ".xiaohongshu.com",
|
|
23673
|
+
url: "https://creator.xiaohongshu.com",
|
|
23674
|
+
httpOnly: true
|
|
23734
23675
|
};
|
|
23735
|
-
const
|
|
23736
|
-
|
|
23737
|
-
|
|
23738
|
-
|
|
23739
|
-
|
|
23740
|
-
|
|
23741
|
-
|
|
23742
|
-
|
|
23743
|
-
|
|
23744
|
-
|
|
23745
|
-
|
|
23746
|
-
|
|
23747
|
-
|
|
23748
|
-
|
|
23749
|
-
|
|
23676
|
+
const page = await task.createPage({
|
|
23677
|
+
show: task.debug,
|
|
23678
|
+
url: params.url || "https://creator.xiaohongshu.com/publish/publish",
|
|
23679
|
+
cookies: params.cookies?.map((it)=>({
|
|
23680
|
+
...it,
|
|
23681
|
+
...commonCookies
|
|
23682
|
+
}))
|
|
23683
|
+
});
|
|
23684
|
+
await updateTaskState?.({
|
|
23685
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.ACTION,
|
|
23686
|
+
connectAddress: task.steelConnector?.getProxyUrl(task.sessionId || "", "v1/sessions/debug"),
|
|
23687
|
+
sessionId: task.sessionId
|
|
23688
|
+
});
|
|
23689
|
+
const tmpCachePath = task.getTmpPath();
|
|
23690
|
+
const selectAddress = async (selector, address)=>{
|
|
23691
|
+
const instance = "string" == typeof selector ? page.locator(selector) : selector;
|
|
23692
|
+
await instance.click();
|
|
23693
|
+
await instance.locator("input").fill(address);
|
|
23694
|
+
const poperInstance = page.locator('.d-popover:not([style*="display: none"]) .d-options .d-grid-item');
|
|
23695
|
+
await poperInstance.first().waitFor();
|
|
23696
|
+
await poperInstance.first().click();
|
|
23750
23697
|
};
|
|
23751
|
-
|
|
23752
|
-
|
|
23753
|
-
|
|
23754
|
-
|
|
23755
|
-
|
|
23756
|
-
|
|
23757
|
-
|
|
23758
|
-
|
|
23759
|
-
|
|
23760
|
-
|
|
23761
|
-
|
|
23698
|
+
const selectDate = async (selector, date)=>{
|
|
23699
|
+
const instance = "string" == typeof selector ? page.locator(selector) : selector;
|
|
23700
|
+
await instance.click();
|
|
23701
|
+
await instance.fill(date);
|
|
23702
|
+
await instance.blur();
|
|
23703
|
+
};
|
|
23704
|
+
const getPoperInstance = async ()=>{
|
|
23705
|
+
await page.waitForTimeout(500);
|
|
23706
|
+
const elements = page.locator(".d-popover");
|
|
23707
|
+
const count = await elements.count();
|
|
23708
|
+
const visibleElements = [];
|
|
23709
|
+
for(let i = 0; i < count; i++){
|
|
23710
|
+
const element = elements.nth(i);
|
|
23711
|
+
const style = await element.getAttribute("style");
|
|
23712
|
+
if (style && !style.includes("display: none")) visibleElements.push(element);
|
|
23713
|
+
}
|
|
23714
|
+
if (visibleElements.length > 0) return visibleElements[visibleElements.length - 1];
|
|
23715
|
+
throw new Error("未找到 popover 弹窗");
|
|
23716
|
+
};
|
|
23717
|
+
const getDialogInstance = async ()=>{
|
|
23718
|
+
await page.waitForTimeout(1000);
|
|
23719
|
+
const elements = page.locator(".el-dialog");
|
|
23720
|
+
return elements.last();
|
|
23721
|
+
};
|
|
23722
|
+
try {
|
|
23723
|
+
await page.waitForSelector("#CreatorPlatform", {
|
|
23724
|
+
state: "visible"
|
|
23725
|
+
});
|
|
23726
|
+
} catch (error) {
|
|
23762
23727
|
return {
|
|
23763
23728
|
code: 414,
|
|
23764
|
-
message: "
|
|
23765
|
-
data:
|
|
23729
|
+
message: "登录失效",
|
|
23730
|
+
data: page.url()
|
|
23766
23731
|
};
|
|
23767
23732
|
}
|
|
23768
|
-
|
|
23769
|
-
|
|
23770
|
-
|
|
23771
|
-
|
|
23772
|
-
|
|
23773
|
-
|
|
23774
|
-
|
|
23775
|
-
|
|
23776
|
-
|
|
23777
|
-
|
|
23778
|
-
|
|
23779
|
-
|
|
23780
|
-
|
|
23781
|
-
|
|
23782
|
-
type: "sort_type"
|
|
23783
|
-
},
|
|
23784
|
-
{
|
|
23785
|
-
tags: [
|
|
23786
|
-
"不限"
|
|
23787
|
-
],
|
|
23788
|
-
type: "filter_note_type"
|
|
23789
|
-
},
|
|
23790
|
-
{
|
|
23791
|
-
tags: [
|
|
23792
|
-
params.time_filter
|
|
23793
|
-
],
|
|
23794
|
-
type: "filter_note_time"
|
|
23795
|
-
},
|
|
23796
|
-
{
|
|
23797
|
-
tags: [
|
|
23798
|
-
"不限"
|
|
23799
|
-
],
|
|
23800
|
-
type: "filter_note_range"
|
|
23801
|
-
},
|
|
23802
|
-
{
|
|
23803
|
-
tags: [
|
|
23804
|
-
"不限"
|
|
23805
|
-
],
|
|
23806
|
-
type: "filter_pos_distance"
|
|
23807
|
-
}
|
|
23808
|
-
],
|
|
23809
|
-
keyword: params.keyword,
|
|
23810
|
-
note_type: 0,
|
|
23811
|
-
page: params.page,
|
|
23812
|
-
page_size: params.page_size,
|
|
23813
|
-
search_id: createSearchId() + (params.sort_type || params.time_filter ? `@${createSearchId()}` : ""),
|
|
23814
|
-
sort: "general"
|
|
23815
|
-
};
|
|
23816
|
-
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
23817
|
-
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
23818
|
-
return acc;
|
|
23819
|
-
}, {});
|
|
23820
|
-
const searchXsHeader = xiaohongshuWebSearch_xsEncrypt.signHeadersPost(filterPath, recordCookie, "xhs-pc-web", filterParams);
|
|
23821
|
-
const res = await http.api({
|
|
23822
|
-
method: "post",
|
|
23823
|
-
url: "https://edith.xiaohongshu.com/api/sns/web/v1/search/notes",
|
|
23824
|
-
data: filterParams,
|
|
23825
|
-
headers: searchXsHeader
|
|
23826
|
-
}, {
|
|
23827
|
-
retries: 3,
|
|
23828
|
-
retryDelay: 20,
|
|
23829
|
-
timeout: 3000
|
|
23733
|
+
await page.locator("#content-area .menu-container .publish-video .btn-wrapper .btn-inner").click();
|
|
23734
|
+
await page.locator('.header-tabs .creator-tab:not([style*="-9999px"])').filter({
|
|
23735
|
+
hasText: /^上传图文$/
|
|
23736
|
+
}).click();
|
|
23737
|
+
const images = await Promise.all(params.banners.map((url)=>{
|
|
23738
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
23739
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
23740
|
+
}));
|
|
23741
|
+
const fileChooser = await page.$("input.upload-input");
|
|
23742
|
+
if (fileChooser) await fileChooser.setInputFiles(images);
|
|
23743
|
+
const titleInstance = page.locator(".input input");
|
|
23744
|
+
await titleInstance.waitFor({
|
|
23745
|
+
state: "visible",
|
|
23746
|
+
timeout: 50000
|
|
23830
23747
|
});
|
|
23831
|
-
|
|
23832
|
-
|
|
23833
|
-
const
|
|
23834
|
-
|
|
23835
|
-
|
|
23836
|
-
const
|
|
23837
|
-
|
|
23838
|
-
|
|
23839
|
-
|
|
23840
|
-
|
|
23841
|
-
|
|
23842
|
-
|
|
23843
|
-
|
|
23844
|
-
|
|
23845
|
-
|
|
23846
|
-
|
|
23847
|
-
const
|
|
23848
|
-
|
|
23849
|
-
|
|
23850
|
-
|
|
23851
|
-
|
|
23852
|
-
|
|
23853
|
-
|
|
23854
|
-
|
|
23855
|
-
|
|
23856
|
-
|
|
23857
|
-
|
|
23858
|
-
|
|
23859
|
-
|
|
23860
|
-
|
|
23861
|
-
|
|
23862
|
-
|
|
23863
|
-
|
|
23864
|
-
|
|
23865
|
-
|
|
23866
|
-
|
|
23867
|
-
|
|
23868
|
-
|
|
23869
|
-
|
|
23870
|
-
|
|
23871
|
-
|
|
23872
|
-
|
|
23873
|
-
|
|
23874
|
-
|
|
23875
|
-
|
|
23876
|
-
|
|
23877
|
-
|
|
23878
|
-
|
|
23879
|
-
|
|
23880
|
-
|
|
23881
|
-
|
|
23882
|
-
|
|
23883
|
-
|
|
23884
|
-
|
|
23885
|
-
|
|
23748
|
+
await titleInstance.click();
|
|
23749
|
+
await titleInstance.fill(params.title);
|
|
23750
|
+
const descInstance = page.locator(".editor-container .tiptap.ProseMirror");
|
|
23751
|
+
await descInstance.click();
|
|
23752
|
+
await descInstance.pressSequentially(params.content.replace(/#.*?\[.*?]#/g, ""));
|
|
23753
|
+
if (params.topic && params.topic.length > 0) for (const it of params.topic){
|
|
23754
|
+
await descInstance.pressSequentially(`#${it.name}`);
|
|
23755
|
+
await page.locator("#creator-editor-topic-container").waitFor({
|
|
23756
|
+
state: "visible"
|
|
23757
|
+
});
|
|
23758
|
+
await page.waitForTimeout(500);
|
|
23759
|
+
await page.locator("#creator-editor-topic-container .item").first().click();
|
|
23760
|
+
}
|
|
23761
|
+
if (params.address) await selectAddress(page.locator(".address-card-wrapper .d-select-wrapper"), params.address.name);
|
|
23762
|
+
if (params.selfDeclaration) {
|
|
23763
|
+
await page.locator(".declaration-wrapper .d-select-wrapper").click();
|
|
23764
|
+
const poperInstance = await getPoperInstance();
|
|
23765
|
+
const selfDeclarationInstance = poperInstance.locator(".d-options .d-option");
|
|
23766
|
+
if ("fictional-rendition" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
|
|
23767
|
+
hasText: "虚构演绎,仅供娱乐"
|
|
23768
|
+
}).click();
|
|
23769
|
+
else if ("ai-generated" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
|
|
23770
|
+
hasText: "笔记含AI合成内容"
|
|
23771
|
+
}).click();
|
|
23772
|
+
else if ("source-statement" === params.selfDeclaration.type) {
|
|
23773
|
+
await selfDeclarationInstance.filter({
|
|
23774
|
+
hasText: /内容来源声明/
|
|
23775
|
+
}).click();
|
|
23776
|
+
const selfDeclarationSecondaryMenuInstance = (await getPoperInstance()).locator(".d-options .d-option");
|
|
23777
|
+
await selfDeclarationSecondaryMenuInstance.first().waitFor();
|
|
23778
|
+
if ("self-labeling" === params.selfDeclaration.childType) await selfDeclarationSecondaryMenuInstance.filter({
|
|
23779
|
+
hasText: "已在正文中自主标注"
|
|
23780
|
+
}).click();
|
|
23781
|
+
else if ("self-shooting" === params.selfDeclaration.childType) {
|
|
23782
|
+
const { shootingDate, shootingLocation } = params.selfDeclaration;
|
|
23783
|
+
await selfDeclarationSecondaryMenuInstance.filter({
|
|
23784
|
+
hasText: "自主拍摄"
|
|
23785
|
+
}).click();
|
|
23786
|
+
const selfShootingPopup = await getDialogInstance();
|
|
23787
|
+
const hasCustomContent = shootingDate || shootingLocation;
|
|
23788
|
+
if (shootingLocation) await selectAddress(selfShootingPopup.locator(".address-input"), shootingLocation.name);
|
|
23789
|
+
if (shootingDate) await selectDate(selfShootingPopup.locator(".date-picker input"), shootingDate);
|
|
23790
|
+
await selfShootingPopup.locator("footer button").filter({
|
|
23791
|
+
hasText: hasCustomContent ? "确认" : "取消"
|
|
23792
|
+
}).click();
|
|
23793
|
+
} else if ("transshipment" === params.selfDeclaration.childType) {
|
|
23794
|
+
await selfDeclarationSecondaryMenuInstance.filter({
|
|
23795
|
+
hasText: "来源转载"
|
|
23796
|
+
}).click();
|
|
23797
|
+
const selfShootingPopup = await getDialogInstance();
|
|
23798
|
+
const sourceMedia = params.selfDeclaration.sourceMedia;
|
|
23799
|
+
if (sourceMedia) await selfShootingPopup.locator(".el-input input").fill(sourceMedia);
|
|
23800
|
+
await selfShootingPopup.locator("footer button").filter({
|
|
23801
|
+
hasText: sourceMedia ? "确认" : "取消"
|
|
23802
|
+
}).click();
|
|
23803
|
+
}
|
|
23804
|
+
}
|
|
23805
|
+
}
|
|
23806
|
+
if ("private" === params.visibleRange) {
|
|
23807
|
+
await page.locator(".publish-page-content-setting-content .d-select-wrapper").last().click();
|
|
23808
|
+
const poperInstance = await getPoperInstance();
|
|
23809
|
+
await poperInstance.locator(".d-options .d-option").filter({
|
|
23810
|
+
hasText: "仅自己可见"
|
|
23811
|
+
}).click();
|
|
23812
|
+
}
|
|
23813
|
+
task._timerRecord.PrePublish = Date.now();
|
|
23814
|
+
const releaseTimeInstance = page.locator("label").filter({
|
|
23815
|
+
hasText: params.isImmediatelyPublish ? "立即发布" : "定时发布"
|
|
23816
|
+
});
|
|
23817
|
+
await releaseTimeInstance.click();
|
|
23818
|
+
if (params.scheduledPublish) await selectDate(".date-picker input", params.scheduledPublish);
|
|
23819
|
+
await page.waitForFunction(()=>{
|
|
23820
|
+
const publishBtn = Array.from(document.querySelectorAll("button")).find((b)=>b.textContent?.trim() === "发布");
|
|
23821
|
+
const uploading = document.querySelector(".progress-container");
|
|
23822
|
+
return !!publishBtn && !uploading;
|
|
23823
|
+
}, {
|
|
23824
|
+
timeout: 180000,
|
|
23825
|
+
polling: 2000
|
|
23826
|
+
});
|
|
23827
|
+
const response = await new Promise((resolve, reject)=>{
|
|
23828
|
+
const handleResponse = async (response)=>{
|
|
23829
|
+
if (response.url().includes("/web_api/sns/v2/note")) {
|
|
23830
|
+
const jsonResponse = await response.json();
|
|
23831
|
+
page.off("response", handleResponse);
|
|
23832
|
+
if (jsonResponse?.success) resolve(jsonResponse?.data?.id);
|
|
23833
|
+
else reject(new Error(jsonResponse?.msg || "发布失败"));
|
|
23834
|
+
}
|
|
23835
|
+
};
|
|
23836
|
+
page.on("response", handleResponse);
|
|
23837
|
+
page.locator(".publish-page-publish-btn button").filter({
|
|
23838
|
+
hasText: "发布"
|
|
23839
|
+
}).click();
|
|
23840
|
+
});
|
|
23841
|
+
await updateTaskState?.({
|
|
23842
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
23843
|
+
result: {
|
|
23844
|
+
response
|
|
23845
|
+
}
|
|
23846
|
+
});
|
|
23847
|
+
await page.close();
|
|
23848
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(response);
|
|
23886
23849
|
};
|
|
23887
|
-
const
|
|
23888
|
-
|
|
23889
|
-
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
23890
|
-
const tmpCachePath = task.getTmpPath();
|
|
23891
|
-
if (params?.selfDeclaration?.type === "source-statement" && "transshipment" === params.selfDeclaration.childType && params.originalBind) return {
|
|
23892
|
-
code: 414,
|
|
23893
|
-
message: "原创声明与转载声明互斥,请重新选择后发布!",
|
|
23894
|
-
data: ""
|
|
23895
|
-
};
|
|
23896
|
-
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
23897
|
-
if (!a1Cookie) return {
|
|
23850
|
+
const xiaohongshuPublish_rpa_server_rpaAction_Server = async (task, params)=>{
|
|
23851
|
+
if (params.originalBind && params?.selfDeclaration?.type === "source-statement") return {
|
|
23898
23852
|
code: 414,
|
|
23899
|
-
message: "
|
|
23853
|
+
message: "已声明原创不可选择“来源转载”",
|
|
23900
23854
|
data: ""
|
|
23901
23855
|
};
|
|
23902
23856
|
const defaultPage = task.steelBrowserContext?.pages()[0];
|
|
@@ -23934,205 +23888,627 @@ const rpaAction_Server_Mock = async (task, params)=>{
|
|
|
23934
23888
|
});
|
|
23935
23889
|
}
|
|
23936
23890
|
}
|
|
23937
|
-
const
|
|
23891
|
+
const tmpCachePath = task.getTmpPath();
|
|
23892
|
+
task.logger?.info("==>进入RPA操作:任务开始,下载图片开始...");
|
|
23893
|
+
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
23894
|
+
const imagePromise = Promise.all(params.banners.map((url)=>{
|
|
23895
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
23896
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
23897
|
+
}));
|
|
23898
|
+
let proxyUrl;
|
|
23899
|
+
if (params.localIP) {
|
|
23900
|
+
const args = [
|
|
23901
|
+
params.localIP,
|
|
23902
|
+
params.proxyLoc,
|
|
23903
|
+
params.accountId
|
|
23904
|
+
];
|
|
23905
|
+
task.logger?.info(`==> 开始获取代理信息:${args}`);
|
|
23906
|
+
const ProxyAgentResult = await ProxyAgent({
|
|
23907
|
+
logger: task.logger
|
|
23908
|
+
}, ...args);
|
|
23909
|
+
task.logger?.info("==> 代理信息获取成功!");
|
|
23910
|
+
proxyUrl = ProxyAgentResult ? `http://${ProxyAgentResult.ip}:${ProxyAgentResult.port}` : void 0;
|
|
23911
|
+
}
|
|
23912
|
+
task.logger?.info("==>开始打开小红书页面...");
|
|
23913
|
+
const page = await task.createPage({
|
|
23938
23914
|
show: task.debug,
|
|
23939
23915
|
cookies: params.cookies,
|
|
23940
|
-
|
|
23916
|
+
proxyUrl,
|
|
23917
|
+
url: params.url || "https://creator.xiaohongshu.com/publish/publish?source=official&from=menu&target=image",
|
|
23918
|
+
...params.viewport ? {
|
|
23919
|
+
viewport: params.viewport
|
|
23920
|
+
} : {}
|
|
23941
23921
|
});
|
|
23922
|
+
task.logger?.info("==>小红书页面打开成功");
|
|
23942
23923
|
await updateTaskState?.({
|
|
23943
|
-
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.ACTION
|
|
23924
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.ACTION,
|
|
23925
|
+
connectAddress: task.steelConnector?.getProxyUrl(task.sessionId || "", "v1/sessions/debug"),
|
|
23926
|
+
sessionId: task.sessionId
|
|
23944
23927
|
});
|
|
23945
|
-
const
|
|
23946
|
-
|
|
23947
|
-
|
|
23948
|
-
|
|
23949
|
-
|
|
23928
|
+
const clickTimeout = 10000;
|
|
23929
|
+
const selectAddress = async (selector, address)=>{
|
|
23930
|
+
const instance = "string" == typeof selector ? page.locator(selector) : selector;
|
|
23931
|
+
await instance.click({
|
|
23932
|
+
timeout: clickTimeout
|
|
23933
|
+
});
|
|
23934
|
+
await instance.locator("input").fill(address);
|
|
23935
|
+
const poperInstance = page.locator('.d-popover:not([style*="display: none"]) .d-options .d-grid-item');
|
|
23936
|
+
await poperInstance.first().waitFor();
|
|
23937
|
+
await poperInstance.first().click({
|
|
23938
|
+
timeout: clickTimeout
|
|
23939
|
+
});
|
|
23950
23940
|
};
|
|
23951
|
-
const
|
|
23952
|
-
|
|
23953
|
-
|
|
23954
|
-
|
|
23955
|
-
|
|
23956
|
-
|
|
23957
|
-
|
|
23958
|
-
|
|
23959
|
-
|
|
23960
|
-
|
|
23961
|
-
|
|
23962
|
-
|
|
23963
|
-
|
|
23964
|
-
|
|
23965
|
-
|
|
23941
|
+
const selectDate = async (selector, date)=>{
|
|
23942
|
+
const instance = "string" == typeof selector ? page.locator(selector) : selector;
|
|
23943
|
+
await instance.click({
|
|
23944
|
+
timeout: clickTimeout
|
|
23945
|
+
});
|
|
23946
|
+
await instance.fill(date);
|
|
23947
|
+
await instance.blur();
|
|
23948
|
+
};
|
|
23949
|
+
const getPoperInstance = async ()=>{
|
|
23950
|
+
await page.waitForTimeout(500);
|
|
23951
|
+
const elements = page.locator(".d-popover");
|
|
23952
|
+
const count = await elements.count();
|
|
23953
|
+
const visibleElements = [];
|
|
23954
|
+
for(let i = 0; i < count; i++){
|
|
23955
|
+
const element = elements.nth(i);
|
|
23956
|
+
const style = await element.getAttribute("style");
|
|
23957
|
+
if (style && !style.includes("display: none")) visibleElements.push(element);
|
|
23958
|
+
}
|
|
23959
|
+
if (visibleElements.length > 0) return visibleElements[visibleElements.length - 1];
|
|
23960
|
+
throw new Error("未找到 popover 弹窗");
|
|
23961
|
+
};
|
|
23962
|
+
const getDialogInstance = async ()=>{
|
|
23963
|
+
await page.waitForTimeout(1000);
|
|
23964
|
+
const elements = page.locator(".el-dialog");
|
|
23965
|
+
return elements.last();
|
|
23966
|
+
};
|
|
23967
|
+
try {
|
|
23968
|
+
await page.waitForSelector("#CreatorPlatform", {
|
|
23969
|
+
state: "attached"
|
|
23970
|
+
});
|
|
23971
|
+
} catch (error) {
|
|
23972
|
+
return {
|
|
23973
|
+
code: 414,
|
|
23974
|
+
message: "登录失效",
|
|
23975
|
+
data: page.url()
|
|
23976
|
+
};
|
|
23977
|
+
}
|
|
23978
|
+
const images = await imagePromise;
|
|
23979
|
+
task.logger?.info(`==>图片下载完成,共 ${images.length} 张,开始上传图片...`);
|
|
23980
|
+
const fileChooser = await page.waitForSelector("input.upload-input", {
|
|
23981
|
+
timeout: 10000
|
|
23966
23982
|
});
|
|
23967
|
-
|
|
23968
|
-
|
|
23969
|
-
|
|
23970
|
-
|
|
23971
|
-
const errmsg = rpa_server_mock_errnoMap[responseData.code] || response.config.defaultErrorMsg || "文章发布异常,请稍后重试。";
|
|
23972
|
-
return {
|
|
23973
|
-
code: rpa_server_mock_errnoMap[responseData.code] ? 414 : 500,
|
|
23974
|
-
message: errmsg,
|
|
23975
|
-
data: responseData
|
|
23976
|
-
};
|
|
23977
|
-
}
|
|
23983
|
+
if (fileChooser) await fileChooser.setInputFiles(images, {
|
|
23984
|
+
timeout: 60000
|
|
23985
|
+
}).catch((err)=>{
|
|
23986
|
+
task.logger?.error(`设置上传文件失败:${err.message}`);
|
|
23978
23987
|
});
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
|
|
23982
|
-
|
|
23983
|
-
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
|
|
23989
|
-
|
|
23990
|
-
|
|
23991
|
-
|
|
23992
|
-
|
|
23993
|
-
|
|
23994
|
-
|
|
23995
|
-
|
|
23996
|
-
|
|
23997
|
-
|
|
23998
|
-
|
|
23999
|
-
|
|
24000
|
-
|
|
24001
|
-
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
24002
|
-
headers: fetchCoverXsHeader,
|
|
24003
|
-
params: fetchCoverParams
|
|
24004
|
-
}, {
|
|
24005
|
-
retries: 3,
|
|
24006
|
-
retryDelay: 20,
|
|
24007
|
-
timeout: 3000
|
|
24008
|
-
});
|
|
24009
|
-
for (const item of batchCoverIdInfo.data.uploadTempPermits)for (const fileId of item.fileIds)uploadInfos.push({
|
|
24010
|
-
bucket: item.bucket || "",
|
|
24011
|
-
uploadAddr: item.uploadAddr || "",
|
|
24012
|
-
fileIds: fileId,
|
|
24013
|
-
token: item.token || ""
|
|
24014
|
-
});
|
|
24015
|
-
}
|
|
24016
|
-
} else {
|
|
24017
|
-
const coverIdInfo = await proxyHttp.api({
|
|
24018
|
-
method: "get",
|
|
24019
|
-
baseURL: "https://creator.xiaohongshu.com",
|
|
24020
|
-
url: fetchCoverUrl,
|
|
24021
|
-
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
24022
|
-
headers: fetchCoverXsHeader,
|
|
24023
|
-
params: fetchCoverParams
|
|
24024
|
-
}, {
|
|
24025
|
-
retries: 3,
|
|
24026
|
-
retryDelay: 20,
|
|
24027
|
-
timeout: 3000
|
|
23988
|
+
else task.logger?.error("文件上传输入框未找到");
|
|
23989
|
+
task.logger?.info("==>图片上传完成,开始渲染预览图...");
|
|
23990
|
+
const titleInstance = page.locator(".input input");
|
|
23991
|
+
await titleInstance.waitFor({
|
|
23992
|
+
state: "attached",
|
|
23993
|
+
timeout: 60000
|
|
23994
|
+
});
|
|
23995
|
+
await titleInstance.click({
|
|
23996
|
+
timeout: 24 * clickTimeout
|
|
23997
|
+
});
|
|
23998
|
+
task.logger?.info("==> 预览图渲染成功,开始RPA操作!");
|
|
23999
|
+
await titleInstance.fill(params.title);
|
|
24000
|
+
const descInstance = page.locator(".editor-container .tiptap.ProseMirror");
|
|
24001
|
+
await descInstance.click({
|
|
24002
|
+
timeout: clickTimeout
|
|
24003
|
+
});
|
|
24004
|
+
await descInstance.fill(`${params.content.replace(/#.*?\[.*?]#/g, "")}\n`);
|
|
24005
|
+
await page.keyboard.press("Control+End");
|
|
24006
|
+
if (params.topic && params.topic.length > 0) for (const it of params.topic){
|
|
24007
|
+
await page.keyboard.insertText(`#${it.name}`);
|
|
24008
|
+
await page.locator(".ql-mention-loading").waitFor({
|
|
24009
|
+
state: "detached"
|
|
24028
24010
|
});
|
|
24029
|
-
|
|
24030
|
-
|
|
24031
|
-
|
|
24032
|
-
fileIds: fileId,
|
|
24033
|
-
token: item.token || ""
|
|
24011
|
+
await page.waitForTimeout(1000);
|
|
24012
|
+
await page.locator("#creator-editor-topic-container .item.is-selected").click({
|
|
24013
|
+
timeout: clickTimeout
|
|
24034
24014
|
});
|
|
24015
|
+
await page.keyboard.press("Control+End");
|
|
24035
24016
|
}
|
|
24036
|
-
|
|
24037
|
-
|
|
24038
|
-
|
|
24039
|
-
|
|
24040
|
-
|
|
24041
|
-
|
|
24042
|
-
|
|
24043
|
-
|
|
24044
|
-
|
|
24045
|
-
|
|
24046
|
-
|
|
24047
|
-
|
|
24048
|
-
|
|
24049
|
-
|
|
24050
|
-
const
|
|
24051
|
-
|
|
24052
|
-
|
|
24053
|
-
|
|
24054
|
-
|
|
24055
|
-
|
|
24056
|
-
|
|
24057
|
-
|
|
24058
|
-
|
|
24059
|
-
|
|
24060
|
-
|
|
24061
|
-
|
|
24062
|
-
|
|
24063
|
-
|
|
24064
|
-
|
|
24065
|
-
|
|
24066
|
-
|
|
24067
|
-
|
|
24068
|
-
|
|
24069
|
-
|
|
24070
|
-
|
|
24071
|
-
|
|
24017
|
+
const container = page.locator(".plugin.editor-container");
|
|
24018
|
+
await container.focus();
|
|
24019
|
+
await page.mouse.wheel(0, 500);
|
|
24020
|
+
if (params.address) await selectAddress(page.locator(".media-extension .address-input").filter({
|
|
24021
|
+
hasText: "添加地点"
|
|
24022
|
+
}), params.address.name);
|
|
24023
|
+
if (params.collectionBind) {
|
|
24024
|
+
await page.locator(".media-extension .collection-container").filter({
|
|
24025
|
+
hasText: "添加合集"
|
|
24026
|
+
}).click({
|
|
24027
|
+
timeout: clickTimeout
|
|
24028
|
+
});
|
|
24029
|
+
const collectionName = params.collectionBind.name;
|
|
24030
|
+
const collectionBindInstance = await getPoperInstance();
|
|
24031
|
+
const collectionItemInstance = collectionBindInstance.locator(".d-grid-item .item-label", {
|
|
24032
|
+
hasText: collectionName
|
|
24033
|
+
});
|
|
24034
|
+
await collectionBindInstance.locator(".loading").waitFor({
|
|
24035
|
+
state: "detached"
|
|
24036
|
+
});
|
|
24037
|
+
await collectionItemInstance.click({
|
|
24038
|
+
timeout: clickTimeout
|
|
24039
|
+
});
|
|
24040
|
+
}
|
|
24041
|
+
if (params.groupBind) {
|
|
24042
|
+
await page.locator(".media-extension .address-input").filter({
|
|
24043
|
+
hasText: "选择群聊"
|
|
24044
|
+
}).click({
|
|
24045
|
+
timeout: clickTimeout
|
|
24046
|
+
});
|
|
24047
|
+
const groupBindName = params.groupBind.group_name;
|
|
24048
|
+
const groupBindInstance = await getPoperInstance();
|
|
24049
|
+
const groupItemInstance = groupBindInstance.locator(".d-grid-item .name", {
|
|
24050
|
+
hasText: groupBindName
|
|
24051
|
+
});
|
|
24052
|
+
await groupBindInstance.locator(".loading").waitFor({
|
|
24053
|
+
state: "detached"
|
|
24054
|
+
});
|
|
24055
|
+
await groupItemInstance.click({
|
|
24056
|
+
timeout: clickTimeout
|
|
24057
|
+
});
|
|
24058
|
+
}
|
|
24059
|
+
const OriginalBindBtn = page.locator(".btn-text.red", {
|
|
24060
|
+
hasText: "去声明"
|
|
24061
|
+
});
|
|
24062
|
+
const isOriginalBindBtnVisible = await OriginalBindBtn.isVisible();
|
|
24063
|
+
if (isOriginalBindBtnVisible && params.originalBind) {
|
|
24064
|
+
await OriginalBindBtn.click({
|
|
24065
|
+
timeout: clickTimeout
|
|
24066
|
+
});
|
|
24067
|
+
const poperInstance = await getPoperInstance();
|
|
24068
|
+
await poperInstance.locator(".d-checkbox-simulator").click({
|
|
24069
|
+
timeout: clickTimeout
|
|
24070
|
+
});
|
|
24071
|
+
await poperInstance.locator(".footer .custom-button.bg-red").click({
|
|
24072
|
+
timeout: clickTimeout
|
|
24073
|
+
});
|
|
24074
|
+
}
|
|
24075
|
+
if (params.selfDeclaration) {
|
|
24076
|
+
await page.locator(".media-settings .flexbox").filter({
|
|
24077
|
+
hasText: "内容类型声明"
|
|
24078
|
+
}).locator(".d-select-placeholder").click({
|
|
24079
|
+
timeout: clickTimeout
|
|
24080
|
+
});
|
|
24081
|
+
const poperInstance = await getPoperInstance();
|
|
24082
|
+
const selfDeclarationInstance = poperInstance.locator(".d-options .d-option");
|
|
24083
|
+
if ("fictional-rendition" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
|
|
24084
|
+
hasText: "虚构演绎,仅供娱乐"
|
|
24085
|
+
}).click({
|
|
24086
|
+
timeout: clickTimeout
|
|
24087
|
+
});
|
|
24088
|
+
else if ("ai-generated" === params.selfDeclaration.type) await selfDeclarationInstance.filter({
|
|
24089
|
+
hasText: "笔记含AI合成内容"
|
|
24090
|
+
}).click({
|
|
24091
|
+
timeout: clickTimeout
|
|
24092
|
+
});
|
|
24093
|
+
else if ("source-statement" === params.selfDeclaration.type) {
|
|
24094
|
+
await selfDeclarationInstance.filter({
|
|
24095
|
+
hasText: /内容来源声明/
|
|
24096
|
+
}).click({
|
|
24097
|
+
timeout: clickTimeout
|
|
24098
|
+
});
|
|
24099
|
+
const selfDeclarationSecondaryMenuInstance = (await getPoperInstance()).locator(".d-options .d-option");
|
|
24100
|
+
await selfDeclarationSecondaryMenuInstance.first().waitFor();
|
|
24101
|
+
if ("self-labeling" === params.selfDeclaration.childType) await selfDeclarationSecondaryMenuInstance.filter({
|
|
24102
|
+
hasText: "已在正文中自主标注"
|
|
24103
|
+
}).click({
|
|
24104
|
+
timeout: clickTimeout
|
|
24105
|
+
});
|
|
24106
|
+
else if ("self-shooting" === params.selfDeclaration.childType) {
|
|
24107
|
+
const { shootingDate, shootingLocation } = params.selfDeclaration;
|
|
24108
|
+
await selfDeclarationSecondaryMenuInstance.filter({
|
|
24109
|
+
hasText: "自主拍摄"
|
|
24110
|
+
}).click({
|
|
24111
|
+
timeout: clickTimeout
|
|
24112
|
+
});
|
|
24113
|
+
const selfShootingPopup = await getDialogInstance();
|
|
24114
|
+
const hasCustomContent = shootingDate || shootingLocation;
|
|
24115
|
+
if (shootingLocation) await selectAddress(selfShootingPopup.locator(".address-input"), shootingLocation.name);
|
|
24116
|
+
if (shootingDate) await selectDate(selfShootingPopup.locator(".date-picker input"), shootingDate);
|
|
24117
|
+
await selfShootingPopup.locator("footer button").filter({
|
|
24118
|
+
hasText: hasCustomContent ? "确认" : "取消"
|
|
24119
|
+
}).click({
|
|
24120
|
+
timeout: clickTimeout
|
|
24121
|
+
});
|
|
24122
|
+
} else if ("transshipment" === params.selfDeclaration.childType) {
|
|
24123
|
+
await selfDeclarationSecondaryMenuInstance.filter({
|
|
24124
|
+
hasText: "来源转载"
|
|
24125
|
+
}).click({
|
|
24126
|
+
timeout: clickTimeout
|
|
24127
|
+
});
|
|
24128
|
+
const selfShootingPopup = await getDialogInstance();
|
|
24129
|
+
const sourceMedia = params.selfDeclaration.sourceMedia;
|
|
24130
|
+
if (sourceMedia) await selfShootingPopup.locator(".el-input input").fill(sourceMedia);
|
|
24131
|
+
await selfShootingPopup.locator("footer button").filter({
|
|
24132
|
+
hasText: sourceMedia ? "确认" : "取消"
|
|
24133
|
+
}).click({
|
|
24134
|
+
timeout: clickTimeout
|
|
24072
24135
|
});
|
|
24073
|
-
return {
|
|
24074
|
-
ossFileId,
|
|
24075
|
-
ossToken
|
|
24076
|
-
};
|
|
24077
|
-
} catch (error) {
|
|
24078
|
-
task.logger.warn(`上传图片 ${index + 1}:使用 bucket ${ossDomain} 失败,尝试下一个可用 bucket。错误信息:${error.message}`);
|
|
24079
|
-
attempt++;
|
|
24080
24136
|
}
|
|
24081
24137
|
}
|
|
24138
|
+
}
|
|
24139
|
+
if ("public" !== params.visibleRange) {
|
|
24140
|
+
await page.locator(".media-settings .flexbox").filter({
|
|
24141
|
+
hasText: "可见范围"
|
|
24142
|
+
}).locator(".d-select-wrapper").click({
|
|
24143
|
+
timeout: clickTimeout
|
|
24144
|
+
});
|
|
24145
|
+
const poperInstance = await getPoperInstance();
|
|
24146
|
+
const visibleText = "friends" === params.visibleRange ? "好友可见" : "仅自己可见";
|
|
24147
|
+
await poperInstance.locator(".d-options .custom-option").filter({
|
|
24148
|
+
hasText: visibleText
|
|
24149
|
+
}).click({
|
|
24150
|
+
timeout: clickTimeout
|
|
24151
|
+
});
|
|
24152
|
+
}
|
|
24153
|
+
async function setSwitch(page, label, target) {
|
|
24154
|
+
const item = page.locator(".d-new-form-item", {
|
|
24155
|
+
has: page.locator(".d-form-item__label", {
|
|
24156
|
+
hasText: label
|
|
24157
|
+
})
|
|
24158
|
+
});
|
|
24159
|
+
const switchUI = item.locator(".d-switch-simulator");
|
|
24160
|
+
const cls = await switchUI.getAttribute("class");
|
|
24161
|
+
const isChecked = cls?.includes("checked") || true;
|
|
24162
|
+
if (isChecked !== target) await switchUI.click({
|
|
24163
|
+
timeout: clickTimeout
|
|
24164
|
+
});
|
|
24165
|
+
}
|
|
24166
|
+
if (!params.coProduceBind) await setSwitch(page, "允许合拍", false);
|
|
24167
|
+
if (!params.noteCopyBind) await setSwitch(page, "允许正文复制", false);
|
|
24168
|
+
const releaseTimeInstance = page.locator("label").filter({
|
|
24169
|
+
hasText: params.isImmediatelyPublish ? "立即发布" : "定时发布"
|
|
24170
|
+
});
|
|
24171
|
+
await releaseTimeInstance.click({
|
|
24172
|
+
timeout: clickTimeout
|
|
24173
|
+
});
|
|
24174
|
+
if (params.scheduledPublish) await selectDate(".date-picker input", params.scheduledPublish);
|
|
24175
|
+
const imgPreviewArea = page.locator(".img-preview-area");
|
|
24176
|
+
try {
|
|
24177
|
+
await imgPreviewArea.locator(".mask.uploading").waitFor({
|
|
24178
|
+
state: "hidden",
|
|
24179
|
+
timeout: 50000
|
|
24180
|
+
});
|
|
24181
|
+
} catch (error) {
|
|
24182
|
+
throw new Error("上传图片超时,请重试!");
|
|
24183
|
+
}
|
|
24184
|
+
if (MockPublish) {
|
|
24185
|
+
const message = "文章模拟发布成功";
|
|
24186
|
+
const data = "123456789";
|
|
24187
|
+
await updateTaskState?.({
|
|
24188
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
24189
|
+
result: {
|
|
24190
|
+
response: data
|
|
24191
|
+
}
|
|
24192
|
+
});
|
|
24193
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(data, message);
|
|
24194
|
+
}
|
|
24195
|
+
const response = await new Promise((resolve)=>{
|
|
24196
|
+
const handleResponse = async (response)=>{
|
|
24197
|
+
if (response.url().includes("/web_api/sns/v2/note")) {
|
|
24198
|
+
const jsonResponse = await response.json();
|
|
24199
|
+
page.off("response", handleResponse);
|
|
24200
|
+
resolve(jsonResponse);
|
|
24201
|
+
}
|
|
24202
|
+
};
|
|
24203
|
+
page.on("response", handleResponse);
|
|
24204
|
+
page.locator(".submit .publishBtn").click({
|
|
24205
|
+
timeout: clickTimeout
|
|
24206
|
+
});
|
|
24207
|
+
page.waitForSelector(".d-toast-icon-danger", {
|
|
24208
|
+
state: "visible",
|
|
24209
|
+
timeout: 2000
|
|
24210
|
+
}).then(async ()=>{
|
|
24211
|
+
await page.waitForTimeout(300);
|
|
24212
|
+
const toastDesc = await page.locator(".d-toast-description").textContent();
|
|
24213
|
+
const desc = toastDesc?.trim();
|
|
24214
|
+
page.off("response", handleResponse);
|
|
24215
|
+
resolve({
|
|
24216
|
+
success: false,
|
|
24217
|
+
msg: desc || "未知错误"
|
|
24218
|
+
});
|
|
24219
|
+
}).catch(()=>{});
|
|
24220
|
+
setTimeout(()=>{
|
|
24221
|
+
page.off("response", handleResponse);
|
|
24222
|
+
resolve({
|
|
24223
|
+
success: false,
|
|
24224
|
+
msg: "发布超时"
|
|
24225
|
+
});
|
|
24226
|
+
}, 7000);
|
|
24227
|
+
});
|
|
24228
|
+
if (!response?.success) {
|
|
24229
|
+
const msg = `发布失败:${response?.msg || "未知错误"}`;
|
|
24230
|
+
await updateTaskState?.({
|
|
24231
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.FAILED,
|
|
24232
|
+
error: msg
|
|
24233
|
+
});
|
|
24234
|
+
await page.close();
|
|
24082
24235
|
return {
|
|
24083
|
-
|
|
24084
|
-
|
|
24236
|
+
code: 414,
|
|
24237
|
+
message: msg,
|
|
24238
|
+
data: ""
|
|
24085
24239
|
};
|
|
24240
|
+
}
|
|
24241
|
+
await updateTaskState?.({
|
|
24242
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.SUCCESS,
|
|
24243
|
+
result: {
|
|
24244
|
+
response: response?.data?.id || ""
|
|
24245
|
+
}
|
|
24246
|
+
});
|
|
24247
|
+
await page.close();
|
|
24248
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(response?.data?.id || "");
|
|
24249
|
+
};
|
|
24250
|
+
const rpa_server_mock_encode_mnsv2 = __webpack_require__("./src/utils/xhs_ob/x_s.encoder.js");
|
|
24251
|
+
function Md5(input) {
|
|
24252
|
+
return __WEBPACK_EXTERNAL_MODULE_node_crypto_9ba42079__["default"].createHash("md5").update(input).digest("hex");
|
|
24253
|
+
}
|
|
24254
|
+
const rpa_server_mock_errnoMap = {
|
|
24255
|
+
"-1": "未知拦截器错误,请稍后重试。",
|
|
24256
|
+
915: "所属C端账号手机号被修改,请重新登录",
|
|
24257
|
+
914: "所属C端账号密码被修改,请重新登录",
|
|
24258
|
+
903: "账户已登出,需重新登陆重试!",
|
|
24259
|
+
902: "登录已过期,请重新登录!",
|
|
24260
|
+
906: "账号存在风险,请重新登录!",
|
|
24261
|
+
"-9136": "因违反社区规范禁止发笔记,请检查账号状态!"
|
|
24262
|
+
};
|
|
24263
|
+
const rpa_server_mock_xsEncrypt = new Xhshow();
|
|
24264
|
+
const rpaAction_Server_Mock = async (task, params)=>{
|
|
24265
|
+
const updateTaskState = task.taskStageStore?.update?.bind(task.taskStageStore, task.taskId || "");
|
|
24266
|
+
const tmpCachePath = task.getTmpPath();
|
|
24267
|
+
if (params?.selfDeclaration?.type === "source-statement" && "transshipment" === params.selfDeclaration.childType && params.originalBind) return {
|
|
24268
|
+
code: 414,
|
|
24269
|
+
message: "原创声明与转载声明互斥,请重新选择后发布!",
|
|
24270
|
+
data: ""
|
|
24086
24271
|
};
|
|
24087
|
-
const
|
|
24088
|
-
|
|
24089
|
-
if (invalidUpload) return {
|
|
24272
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
24273
|
+
if (!a1Cookie) return {
|
|
24090
24274
|
code: 414,
|
|
24091
|
-
message: "
|
|
24275
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
24092
24276
|
data: ""
|
|
24093
24277
|
};
|
|
24094
|
-
|
|
24095
|
-
|
|
24096
|
-
|
|
24097
|
-
|
|
24098
|
-
|
|
24099
|
-
|
|
24100
|
-
|
|
24101
|
-
|
|
24102
|
-
|
|
24103
|
-
|
|
24104
|
-
|
|
24105
|
-
|
|
24106
|
-
|
|
24107
|
-
|
|
24108
|
-
|
|
24109
|
-
|
|
24278
|
+
const defaultPage = task.steelBrowserContext?.pages()[0];
|
|
24279
|
+
if (defaultPage) {
|
|
24280
|
+
if (!defaultPage._routeRegistered) {
|
|
24281
|
+
defaultPage._routeRegistered = true;
|
|
24282
|
+
const blockedPatterns = [
|
|
24283
|
+
"**/ffmpeg-core.wasm*",
|
|
24284
|
+
"**/apm-fe.xiaohongshu.com*",
|
|
24285
|
+
"**/t2.xiaohongshu.com*",
|
|
24286
|
+
"**/fe-video-qc.xhscdn.com*"
|
|
24287
|
+
].map((pattern)=>new RegExp(pattern.replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*")));
|
|
24288
|
+
await defaultPage.route("**/*", async (route)=>{
|
|
24289
|
+
const req = route.request();
|
|
24290
|
+
const url = req.url();
|
|
24291
|
+
const blocked = blockedPatterns.some((regex)=>regex.test(url));
|
|
24292
|
+
if (!blocked) return route.continue();
|
|
24293
|
+
if ("OPTIONS" === req.method()) {
|
|
24294
|
+
console.log("处理 OPTIONS 预检:", url);
|
|
24295
|
+
await route.fulfill({
|
|
24296
|
+
status: 204,
|
|
24297
|
+
headers: {
|
|
24298
|
+
"access-control-allow-origin": "*",
|
|
24299
|
+
"access-control-allow-methods": "GET,POST,OPTIONS,PUT,DELETE",
|
|
24300
|
+
"access-control-allow-headers": "*"
|
|
24301
|
+
},
|
|
24302
|
+
body: ""
|
|
24303
|
+
});
|
|
24304
|
+
return;
|
|
24305
|
+
}
|
|
24306
|
+
await route.fulfill({
|
|
24307
|
+
status: 204,
|
|
24308
|
+
body: ""
|
|
24309
|
+
});
|
|
24110
24310
|
});
|
|
24111
|
-
Object.assign(topic, createTopic.data.topic_infos[0]);
|
|
24112
24311
|
}
|
|
24113
|
-
}
|
|
24114
|
-
const
|
|
24115
|
-
|
|
24116
|
-
|
|
24117
|
-
|
|
24312
|
+
}
|
|
24313
|
+
const pagePromise = task.createPage({
|
|
24314
|
+
show: task.debug,
|
|
24315
|
+
cookies: params.cookies,
|
|
24316
|
+
url: params.url || "https://creator.xiaohongshu.com/statistics/account/v2?source=official"
|
|
24317
|
+
});
|
|
24318
|
+
await updateTaskState?.({
|
|
24319
|
+
state: __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.TaskState.ACTION
|
|
24320
|
+
});
|
|
24321
|
+
const headers = {
|
|
24322
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
24323
|
+
origin: "https://creator.xiaohongshu.com",
|
|
24324
|
+
referer: "https://creator.xiaohongshu.com/",
|
|
24325
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
|
|
24118
24326
|
};
|
|
24119
|
-
const
|
|
24120
|
-
|
|
24121
|
-
|
|
24122
|
-
|
|
24123
|
-
|
|
24124
|
-
|
|
24125
|
-
|
|
24126
|
-
|
|
24127
|
-
|
|
24128
|
-
|
|
24129
|
-
|
|
24130
|
-
|
|
24131
|
-
|
|
24132
|
-
|
|
24133
|
-
|
|
24134
|
-
|
|
24135
|
-
|
|
24327
|
+
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
24328
|
+
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
24329
|
+
return acc;
|
|
24330
|
+
}, {});
|
|
24331
|
+
const args = [
|
|
24332
|
+
{
|
|
24333
|
+
headers
|
|
24334
|
+
},
|
|
24335
|
+
task.logger,
|
|
24336
|
+
params.proxyLoc,
|
|
24337
|
+
params.localIP,
|
|
24338
|
+
params.accountId
|
|
24339
|
+
];
|
|
24340
|
+
const http = new Http({
|
|
24341
|
+
headers
|
|
24342
|
+
});
|
|
24343
|
+
const proxyHttp = new Http(...args);
|
|
24344
|
+
proxyHttp.addResponseInterceptor((response)=>{
|
|
24345
|
+
const responseData = response.data;
|
|
24346
|
+
if (response && responseData?.code && 0 !== responseData.code || responseData?.code && !responseData.success) {
|
|
24347
|
+
const errmsg = rpa_server_mock_errnoMap[responseData.code] || response.config.defaultErrorMsg || "文章发布异常,请稍后重试。";
|
|
24348
|
+
return {
|
|
24349
|
+
code: rpa_server_mock_errnoMap[responseData.code] ? 414 : 500,
|
|
24350
|
+
message: errmsg,
|
|
24351
|
+
data: responseData
|
|
24352
|
+
};
|
|
24353
|
+
}
|
|
24354
|
+
});
|
|
24355
|
+
const fetchCoverUrl = "/api/media/v1/upload/creator/permit";
|
|
24356
|
+
const fetchCoverParams = {
|
|
24357
|
+
biz_name: "spectrum",
|
|
24358
|
+
scene: "image",
|
|
24359
|
+
file_count: params.banners.length,
|
|
24360
|
+
version: 1,
|
|
24361
|
+
source: "web"
|
|
24362
|
+
};
|
|
24363
|
+
const fetchCoverXsHeader = rpa_server_mock_xsEncrypt.signHeadersGet(fetchCoverUrl, recordCookie, "ugc", fetchCoverParams);
|
|
24364
|
+
const uploadInfos = [];
|
|
24365
|
+
if (params.banners.length > 18) {
|
|
24366
|
+
let num = Math.ceil(params.banners.length / 14);
|
|
24367
|
+
for(let i = 0; i < num; i++){
|
|
24368
|
+
const start = 14 * i;
|
|
24369
|
+
params.banners.length;
|
|
24370
|
+
({
|
|
24371
|
+
...fetchCoverParams
|
|
24372
|
+
});
|
|
24373
|
+
const batchCoverIdInfo = await proxyHttp.api({
|
|
24374
|
+
method: "get",
|
|
24375
|
+
baseURL: "https://creator.xiaohongshu.com",
|
|
24376
|
+
url: fetchCoverUrl,
|
|
24377
|
+
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
24378
|
+
headers: fetchCoverXsHeader,
|
|
24379
|
+
params: fetchCoverParams
|
|
24380
|
+
}, {
|
|
24381
|
+
retries: 3,
|
|
24382
|
+
retryDelay: 20,
|
|
24383
|
+
timeout: 3000
|
|
24384
|
+
});
|
|
24385
|
+
for (const item of batchCoverIdInfo.data.uploadTempPermits)for (const fileId of item.fileIds)uploadInfos.push({
|
|
24386
|
+
bucket: item.bucket || "",
|
|
24387
|
+
uploadAddr: item.uploadAddr || "",
|
|
24388
|
+
fileIds: fileId,
|
|
24389
|
+
token: item.token || ""
|
|
24390
|
+
});
|
|
24391
|
+
}
|
|
24392
|
+
} else {
|
|
24393
|
+
const coverIdInfo = await proxyHttp.api({
|
|
24394
|
+
method: "get",
|
|
24395
|
+
baseURL: "https://creator.xiaohongshu.com",
|
|
24396
|
+
url: fetchCoverUrl,
|
|
24397
|
+
defaultErrorMsg: "获取小红书用户信息失败,请稍后重试发布。",
|
|
24398
|
+
headers: fetchCoverXsHeader,
|
|
24399
|
+
params: fetchCoverParams
|
|
24400
|
+
}, {
|
|
24401
|
+
retries: 3,
|
|
24402
|
+
retryDelay: 20,
|
|
24403
|
+
timeout: 3000
|
|
24404
|
+
});
|
|
24405
|
+
for (const item of coverIdInfo.data.uploadTempPermits)for (const fileId of item.fileIds)uploadInfos.push({
|
|
24406
|
+
bucket: item.bucket || "",
|
|
24407
|
+
uploadAddr: item.uploadAddr || "",
|
|
24408
|
+
fileIds: fileId,
|
|
24409
|
+
token: item.token || ""
|
|
24410
|
+
});
|
|
24411
|
+
}
|
|
24412
|
+
if (uploadInfos.length < params.banners.length) return {
|
|
24413
|
+
code: 414,
|
|
24414
|
+
message: "可用 OSS bucket 数量不足,无法上传所有图片!",
|
|
24415
|
+
data: ""
|
|
24416
|
+
};
|
|
24417
|
+
if (0 === uploadInfos.length) return {
|
|
24418
|
+
code: 414,
|
|
24419
|
+
message: "图片上传失败,请稍后重试!",
|
|
24420
|
+
data: ""
|
|
24421
|
+
};
|
|
24422
|
+
const availableBuckets = Array.from({
|
|
24423
|
+
length: uploadInfos.length
|
|
24424
|
+
}, (_, i)=>i);
|
|
24425
|
+
const uploadFile = async (url, index)=>{
|
|
24426
|
+
const fileName = (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.getFilenameFromUrl)(url);
|
|
24427
|
+
const localUrl = await (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.downloadImage)(url, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(tmpCachePath, fileName));
|
|
24428
|
+
const fileBuffer = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(localUrl);
|
|
24429
|
+
const MAX_RETRIES = uploadInfos.length;
|
|
24430
|
+
task.logger.debug(`上传图片 ${index + 1}:尝试使用最多 ${MAX_RETRIES} 个 bucket`);
|
|
24431
|
+
let attempt = 0;
|
|
24432
|
+
while(attempt < MAX_RETRIES){
|
|
24433
|
+
const ossBucketIndex = availableBuckets.shift();
|
|
24434
|
+
if (void 0 === ossBucketIndex) break;
|
|
24435
|
+
const currentInfo = uploadInfos[ossBucketIndex];
|
|
24436
|
+
const ossFileId = currentInfo.fileIds;
|
|
24437
|
+
const ossToken = currentInfo.token;
|
|
24438
|
+
const ossDomain = currentInfo.uploadAddr;
|
|
24439
|
+
try {
|
|
24440
|
+
await http.api({
|
|
24441
|
+
method: "put",
|
|
24442
|
+
url: `https://${ossDomain}/${ossFileId}`,
|
|
24443
|
+
data: fileBuffer,
|
|
24444
|
+
headers: {
|
|
24445
|
+
"x-cos-security-token": ossToken
|
|
24446
|
+
},
|
|
24447
|
+
defaultErrorMsg: "图片上传异常,请稍后重试发布。"
|
|
24448
|
+
});
|
|
24449
|
+
return {
|
|
24450
|
+
ossFileId,
|
|
24451
|
+
ossToken
|
|
24452
|
+
};
|
|
24453
|
+
} catch (error) {
|
|
24454
|
+
task.logger.warn(`上传图片 ${index + 1}:使用 bucket ${ossDomain} 失败,尝试下一个可用 bucket。错误信息:${error.message}`);
|
|
24455
|
+
attempt++;
|
|
24456
|
+
}
|
|
24457
|
+
}
|
|
24458
|
+
return {
|
|
24459
|
+
ossFileId: "",
|
|
24460
|
+
ossToken: ""
|
|
24461
|
+
};
|
|
24462
|
+
};
|
|
24463
|
+
const coverInfos = await Promise.all(params.banners.map((it, idx)=>uploadFile(it, idx)));
|
|
24464
|
+
const invalidUpload = coverInfos.find((it)=>"" === it.ossToken || "" === it.ossFileId);
|
|
24465
|
+
if (invalidUpload) return {
|
|
24466
|
+
code: 414,
|
|
24467
|
+
message: "图片上传异常,请稍后重试发布。",
|
|
24468
|
+
data: ""
|
|
24469
|
+
};
|
|
24470
|
+
if (params.topic && params.topic.length > 0) await Promise.all(params.topic.map(async (topic)=>{
|
|
24471
|
+
if (!topic.id) {
|
|
24472
|
+
const topicData = {
|
|
24473
|
+
topic_names: topic.name
|
|
24474
|
+
};
|
|
24475
|
+
const topicXsHeader = rpa_server_mock_xsEncrypt.signHeadersPost("/web_api/sns/capa/postgw/topic/batch_customized", recordCookie, "ugc", topicData);
|
|
24476
|
+
const createTopic = await proxyHttp.api({
|
|
24477
|
+
method: "POST",
|
|
24478
|
+
url: "https://edith.xiaohongshu.com/web_api/sns/capa/postgw/topic/batch_customized",
|
|
24479
|
+
headers: topicXsHeader,
|
|
24480
|
+
data: topicData,
|
|
24481
|
+
defaultErrorMsg: "话题创建异常,请稍后重试。"
|
|
24482
|
+
}, {
|
|
24483
|
+
retries: 3,
|
|
24484
|
+
retryDelay: 20,
|
|
24485
|
+
timeout: 3000
|
|
24486
|
+
});
|
|
24487
|
+
Object.assign(topic, createTopic.data.topic_infos[0]);
|
|
24488
|
+
}
|
|
24489
|
+
}));
|
|
24490
|
+
const visibleRangeMap = {
|
|
24491
|
+
public: 0,
|
|
24492
|
+
private: 1,
|
|
24493
|
+
friends: 4
|
|
24494
|
+
};
|
|
24495
|
+
const publishData = {
|
|
24496
|
+
common: {
|
|
24497
|
+
ats: [],
|
|
24498
|
+
biz_relations: [],
|
|
24499
|
+
desc: params?.content,
|
|
24500
|
+
goods_info: {},
|
|
24501
|
+
hash_tag: params.topic || [],
|
|
24502
|
+
note_id: "",
|
|
24503
|
+
source: JSON.stringify({
|
|
24504
|
+
type: "web",
|
|
24505
|
+
ids: "",
|
|
24506
|
+
extraInfo: '{"systemId":"web"}'
|
|
24507
|
+
}),
|
|
24508
|
+
title: params?.title,
|
|
24509
|
+
type: "normal",
|
|
24510
|
+
privacy_info: {
|
|
24511
|
+
op_type: 1,
|
|
24136
24512
|
type: visibleRangeMap[params.visibleRange]
|
|
24137
24513
|
},
|
|
24138
24514
|
post_loc: params.address ? {
|
|
@@ -24305,6 +24681,622 @@ const rpaAction_Server_Mock = async (task, params)=>{
|
|
|
24305
24681
|
});
|
|
24306
24682
|
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.success)(data, message);
|
|
24307
24683
|
};
|
|
24684
|
+
const FictionalRendition = schemas_object({
|
|
24685
|
+
type: literal("fictional-rendition")
|
|
24686
|
+
});
|
|
24687
|
+
const AIGenerated = schemas_object({
|
|
24688
|
+
type: literal("ai-generated")
|
|
24689
|
+
});
|
|
24690
|
+
const SourceStatement = schemas_object({
|
|
24691
|
+
type: literal("source-statement"),
|
|
24692
|
+
childType: schemas_enum([
|
|
24693
|
+
"self-labeling",
|
|
24694
|
+
"self-shooting",
|
|
24695
|
+
"transshipment"
|
|
24696
|
+
]),
|
|
24697
|
+
shootingLocation: custom().optional(),
|
|
24698
|
+
shootingDate: schemas_string().optional(),
|
|
24699
|
+
sourceMedia: schemas_string().optional()
|
|
24700
|
+
});
|
|
24701
|
+
union([
|
|
24702
|
+
FictionalRendition,
|
|
24703
|
+
AIGenerated,
|
|
24704
|
+
SourceStatement
|
|
24705
|
+
]);
|
|
24706
|
+
const XiaohongshuPublishParamsSchema = ActionCommonParamsSchema.extend({
|
|
24707
|
+
banners: schemas_array(schemas_string()),
|
|
24708
|
+
title: schemas_string(),
|
|
24709
|
+
content: schemas_string(),
|
|
24710
|
+
address: custom().optional(),
|
|
24711
|
+
selfDeclaration: custom().optional(),
|
|
24712
|
+
topic: schemas_array(custom()).optional(),
|
|
24713
|
+
proxyLoc: schemas_string().optional(),
|
|
24714
|
+
localIP: schemas_string().optional(),
|
|
24715
|
+
huiwenToken: schemas_string().optional(),
|
|
24716
|
+
visibleRange: schemas_enum([
|
|
24717
|
+
"public",
|
|
24718
|
+
"private",
|
|
24719
|
+
"friends"
|
|
24720
|
+
]),
|
|
24721
|
+
isImmediatelyPublish: schemas_boolean().optional(),
|
|
24722
|
+
scheduledPublish: schemas_string().optional(),
|
|
24723
|
+
collectionId: schemas_string().optional(),
|
|
24724
|
+
collectionBind: custom().optional(),
|
|
24725
|
+
groupBind: custom().optional(),
|
|
24726
|
+
noteCopyBind: schemas_boolean().optional(),
|
|
24727
|
+
coProduceBind: schemas_boolean().optional(),
|
|
24728
|
+
originalBind: schemas_boolean().optional()
|
|
24729
|
+
});
|
|
24730
|
+
const xiaohongshuPublish = async (task, params)=>{
|
|
24731
|
+
if (DisabledReq) return {
|
|
24732
|
+
code: 414,
|
|
24733
|
+
data: "",
|
|
24734
|
+
message: "临时维护:小红书发布政策调整,本平台小红书发布功能临时暂停服务并进行维护调整,暂时无法正常发布,敬请理解知悉。"
|
|
24735
|
+
};
|
|
24736
|
+
if ("rpa" === params.actionType) return xiaohongshuPublish_rpa_rpaAction(task, params);
|
|
24737
|
+
if ("mockApi" === params.actionType) return xiaohongshuPublish_mock_mockAction(task, params);
|
|
24738
|
+
if ("server" === params.actionType) return xiaohongshuPublish_rpa_server_rpaAction_Server(task, params);
|
|
24739
|
+
return executeAction(xiaohongshuPublish_mock_mockAction, rpaAction_Server_Mock, xiaohongshuPublish_rpa_server_rpaAction_Server)(task, params);
|
|
24740
|
+
};
|
|
24741
|
+
const xiaohongshuWebCommentAction_xsEncrypt = new Xhshow();
|
|
24742
|
+
const xiaohongshuWebCommentAction = async (_task, params)=>{
|
|
24743
|
+
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "点赞相关操作失败", {});
|
|
24744
|
+
const headers = {
|
|
24745
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
24746
|
+
referer: "https://www.xiaohongshu.com/",
|
|
24747
|
+
origin: "https://www.xiaohongshu.com/"
|
|
24748
|
+
};
|
|
24749
|
+
const args = [
|
|
24750
|
+
{
|
|
24751
|
+
headers
|
|
24752
|
+
},
|
|
24753
|
+
_task.logger,
|
|
24754
|
+
params.proxyLoc,
|
|
24755
|
+
params.localIP,
|
|
24756
|
+
params.accountId
|
|
24757
|
+
];
|
|
24758
|
+
const http = new Http(...args);
|
|
24759
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
24760
|
+
if (!a1Cookie) return {
|
|
24761
|
+
code: 414,
|
|
24762
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
24763
|
+
data: []
|
|
24764
|
+
};
|
|
24765
|
+
if (!params.note_id && !params.comment_id && !params.action) return {
|
|
24766
|
+
code: 414,
|
|
24767
|
+
message: "参数缺失,请检查后重试!",
|
|
24768
|
+
data: {}
|
|
24769
|
+
};
|
|
24770
|
+
const actionParams = {
|
|
24771
|
+
note_id: params.note_id,
|
|
24772
|
+
comment_id: params.comment_id
|
|
24773
|
+
};
|
|
24774
|
+
let likeActionRes = {
|
|
24775
|
+
code: 500,
|
|
24776
|
+
success: false,
|
|
24777
|
+
msg: ""
|
|
24778
|
+
};
|
|
24779
|
+
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
24780
|
+
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
24781
|
+
return acc;
|
|
24782
|
+
}, {});
|
|
24783
|
+
switch(params.action){
|
|
24784
|
+
case "like":
|
|
24785
|
+
{
|
|
24786
|
+
const likeAction = "/api/sns/web/v1/comment/like";
|
|
24787
|
+
const likeActionXsHeader = xiaohongshuWebCommentAction_xsEncrypt.signHeadersPost(likeAction, recordCookie, "xhs-pc-web", actionParams);
|
|
24788
|
+
likeActionRes = await http.api({
|
|
24789
|
+
method: "post",
|
|
24790
|
+
url: "https://edith.xiaohongshu.com/api/sns/web/v1/comment/like",
|
|
24791
|
+
data: actionParams,
|
|
24792
|
+
headers: likeActionXsHeader
|
|
24793
|
+
}, {
|
|
24794
|
+
retries: 3,
|
|
24795
|
+
retryDelay: 20,
|
|
24796
|
+
timeout: 3000
|
|
24797
|
+
});
|
|
24798
|
+
break;
|
|
24799
|
+
}
|
|
24800
|
+
case "dislike":
|
|
24801
|
+
{
|
|
24802
|
+
const dislikeMentions = "/api/sns/web/v1/comment/dislike";
|
|
24803
|
+
const dislikeXsHeader = xiaohongshuWebCommentAction_xsEncrypt.signHeadersPost(dislikeMentions, recordCookie, "xhs-pc-web", actionParams);
|
|
24804
|
+
likeActionRes = await http.api({
|
|
24805
|
+
method: "post",
|
|
24806
|
+
url: "https://edith.xiaohongshu.com/api/sns/web/v1/comment/dislike",
|
|
24807
|
+
data: actionParams,
|
|
24808
|
+
headers: dislikeXsHeader
|
|
24809
|
+
}, {
|
|
24810
|
+
retries: 3,
|
|
24811
|
+
retryDelay: 20,
|
|
24812
|
+
timeout: 3000
|
|
24813
|
+
});
|
|
24814
|
+
break;
|
|
24815
|
+
}
|
|
24816
|
+
default:
|
|
24817
|
+
return {
|
|
24818
|
+
code: 414,
|
|
24819
|
+
message: "参数action错误,请重试!",
|
|
24820
|
+
data: {}
|
|
24821
|
+
};
|
|
24822
|
+
}
|
|
24823
|
+
const isSuccess = 0 === likeActionRes.code;
|
|
24824
|
+
const message = `点赞相关操作${isSuccess ? "成功" : `失败,原因:${likeActionRes.msg}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
24825
|
+
const data = isSuccess ? likeActionRes.success : {};
|
|
24826
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
24827
|
+
};
|
|
24828
|
+
const xiaohongshuWebIntimacySearch = async (_task, params)=>{
|
|
24829
|
+
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(0, "搜索@列表数据成功", []);
|
|
24830
|
+
const headers = {
|
|
24831
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
24832
|
+
referer: "https://www.xiaohongshu.com/",
|
|
24833
|
+
origin: "https://www.xiaohongshu.com"
|
|
24834
|
+
};
|
|
24835
|
+
const args = [
|
|
24836
|
+
{
|
|
24837
|
+
headers
|
|
24838
|
+
},
|
|
24839
|
+
_task.logger,
|
|
24840
|
+
params.proxyLoc,
|
|
24841
|
+
params.localIP,
|
|
24842
|
+
params.accountId
|
|
24843
|
+
];
|
|
24844
|
+
const http = new Http(...args);
|
|
24845
|
+
let intimacyDetail = [];
|
|
24846
|
+
const res = await http.api({
|
|
24847
|
+
method: "get",
|
|
24848
|
+
url: `https://edith.xiaohongshu.com/api/sns/web/v1/intimacy/intimacy_list${params.searchValue ? "/search" : ""}`,
|
|
24849
|
+
...params.searchValue ? {
|
|
24850
|
+
params: {
|
|
24851
|
+
keyword: params.searchValue,
|
|
24852
|
+
page: 1,
|
|
24853
|
+
rows: 30
|
|
24854
|
+
}
|
|
24855
|
+
} : {}
|
|
24856
|
+
}, {
|
|
24857
|
+
retries: 3,
|
|
24858
|
+
retryDelay: 20,
|
|
24859
|
+
timeout: 3000
|
|
24860
|
+
});
|
|
24861
|
+
const isSuccess = 0 === res.code;
|
|
24862
|
+
if (isSuccess) intimacyDetail = res.data.items;
|
|
24863
|
+
const message = `搜索@列表数据${isSuccess ? "成功" : `失败,原因:${res.msg}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
24864
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, intimacyDetail);
|
|
24865
|
+
};
|
|
24866
|
+
const xiaohongshuWebMsgRead_xsEncrypt = new Xhshow();
|
|
24867
|
+
const xiaohongshuWebMsgRead = async (_task, params)=>{
|
|
24868
|
+
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "Read指定Tab失败", {});
|
|
24869
|
+
const headers = {
|
|
24870
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
24871
|
+
referer: "https://www.xiaohongshu.com/",
|
|
24872
|
+
origin: "https://www.xiaohongshu.com/"
|
|
24873
|
+
};
|
|
24874
|
+
const args = [
|
|
24875
|
+
{
|
|
24876
|
+
headers
|
|
24877
|
+
},
|
|
24878
|
+
_task.logger,
|
|
24879
|
+
params.proxyLoc,
|
|
24880
|
+
params.localIP,
|
|
24881
|
+
params.accountId
|
|
24882
|
+
];
|
|
24883
|
+
const http = new Http(...args);
|
|
24884
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
24885
|
+
if (!a1Cookie) return {
|
|
24886
|
+
code: 414,
|
|
24887
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
24888
|
+
data: []
|
|
24889
|
+
};
|
|
24890
|
+
if (!params.type) return {
|
|
24891
|
+
code: 414,
|
|
24892
|
+
message: "参数缺失,请检查后重试!",
|
|
24893
|
+
data: {}
|
|
24894
|
+
};
|
|
24895
|
+
const replyParams = {
|
|
24896
|
+
type: params.type
|
|
24897
|
+
};
|
|
24898
|
+
const fatchMentions = "/api/sns/web/v1/message/read";
|
|
24899
|
+
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
24900
|
+
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
24901
|
+
return acc;
|
|
24902
|
+
}, {});
|
|
24903
|
+
const fatchMentionsXsHeader = xiaohongshuWebMsgRead_xsEncrypt.signHeadersPost(fatchMentions, recordCookie, "xhs-pc-web", replyParams);
|
|
24904
|
+
const res = await http.api({
|
|
24905
|
+
method: "post",
|
|
24906
|
+
url: "https://edith.xiaohongshu.com/api/sns/web/v1/message/read",
|
|
24907
|
+
data: replyParams,
|
|
24908
|
+
headers: fatchMentionsXsHeader
|
|
24909
|
+
}, {
|
|
24910
|
+
retries: 3,
|
|
24911
|
+
retryDelay: 20,
|
|
24912
|
+
timeout: 3000
|
|
24913
|
+
});
|
|
24914
|
+
const isSuccess = 0 === res.code;
|
|
24915
|
+
const message = `Read指定Tab${isSuccess ? "成功" : `失败,原因:${res.msg}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
24916
|
+
const data = isSuccess ? res.success : {};
|
|
24917
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
24918
|
+
};
|
|
24919
|
+
const xiaohongshuWebMsgReply_xsEncrypt = new Xhshow();
|
|
24920
|
+
const xiaohongshuWebMsgReply = async (_task, params)=>{
|
|
24921
|
+
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "评论回复失败", {});
|
|
24922
|
+
const headers = {
|
|
24923
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
24924
|
+
referer: "https://www.xiaohongshu.com/",
|
|
24925
|
+
origin: "https://www.xiaohongshu.com/"
|
|
24926
|
+
};
|
|
24927
|
+
const args = [
|
|
24928
|
+
{
|
|
24929
|
+
headers
|
|
24930
|
+
},
|
|
24931
|
+
_task.logger,
|
|
24932
|
+
params.proxyLoc,
|
|
24933
|
+
params.localIP,
|
|
24934
|
+
params.accountId
|
|
24935
|
+
];
|
|
24936
|
+
const http = new Http(...args);
|
|
24937
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
24938
|
+
if (!a1Cookie) return {
|
|
24939
|
+
code: 414,
|
|
24940
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
24941
|
+
data: []
|
|
24942
|
+
};
|
|
24943
|
+
if (!params.note_id || !params.target_comment_id || !params.content) return {
|
|
24944
|
+
code: 414,
|
|
24945
|
+
message: "参数缺失,请检查后重试!",
|
|
24946
|
+
data: {}
|
|
24947
|
+
};
|
|
24948
|
+
const replyParams = {
|
|
24949
|
+
at_users: params.at_users ?? [],
|
|
24950
|
+
content: params.content,
|
|
24951
|
+
note_id: params.note_id,
|
|
24952
|
+
target_comment_id: params.target_comment_id
|
|
24953
|
+
};
|
|
24954
|
+
const replyPath = "/api/sns/web/v1/comment/post";
|
|
24955
|
+
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
24956
|
+
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
24957
|
+
return acc;
|
|
24958
|
+
}, {});
|
|
24959
|
+
const replyXsHeader = xiaohongshuWebMsgReply_xsEncrypt.signHeadersPost(replyPath, recordCookie, "xhs-pc-web", replyParams);
|
|
24960
|
+
const res = await http.api({
|
|
24961
|
+
method: "post",
|
|
24962
|
+
url: "https://edith.xiaohongshu.com/api/sns/web/v1/comment/post",
|
|
24963
|
+
data: replyParams,
|
|
24964
|
+
headers: replyXsHeader
|
|
24965
|
+
}, {
|
|
24966
|
+
retries: 3,
|
|
24967
|
+
retryDelay: 20,
|
|
24968
|
+
timeout: 3000
|
|
24969
|
+
});
|
|
24970
|
+
const isSuccess = 0 === res.code;
|
|
24971
|
+
const message = `评论回复${isSuccess ? "成功" : `失败,原因:${res.msg}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
24972
|
+
const data = isSuccess ? res.data : {};
|
|
24973
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
24974
|
+
};
|
|
24975
|
+
const xiaohongshuWebNoteFeed_xsEncrypt = new xhs_ob_feed_Xhshow();
|
|
24976
|
+
const GenXSCommon = __webpack_require__("./src/utils/XhsXsCommonEnc.js");
|
|
24977
|
+
const xiaohongshuWebNoteFeed = async (_task, params)=>{
|
|
24978
|
+
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "获取指定文章详情失败", {});
|
|
24979
|
+
const headers = {
|
|
24980
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
24981
|
+
referer: "https://www.xiaohongshu.com/",
|
|
24982
|
+
origin: "https://www.xiaohongshu.com/"
|
|
24983
|
+
};
|
|
24984
|
+
const args = [
|
|
24985
|
+
{
|
|
24986
|
+
headers
|
|
24987
|
+
},
|
|
24988
|
+
_task.logger,
|
|
24989
|
+
params.proxyLoc,
|
|
24990
|
+
params.localIP,
|
|
24991
|
+
params.accountId
|
|
24992
|
+
];
|
|
24993
|
+
const http = new Http(...args);
|
|
24994
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
24995
|
+
if (!a1Cookie) return {
|
|
24996
|
+
code: 414,
|
|
24997
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
24998
|
+
data: {}
|
|
24999
|
+
};
|
|
25000
|
+
if (!params.source_note_id && !params.xsec_token) return {
|
|
25001
|
+
code: 414,
|
|
25002
|
+
message: "参数缺失,请检查后重试!",
|
|
25003
|
+
data: {}
|
|
25004
|
+
};
|
|
25005
|
+
const feedParams = {
|
|
25006
|
+
source_note_id: params.source_note_id,
|
|
25007
|
+
image_formats: [
|
|
25008
|
+
"jpg",
|
|
25009
|
+
"webp",
|
|
25010
|
+
"avif"
|
|
25011
|
+
],
|
|
25012
|
+
extra: {
|
|
25013
|
+
need_body_topic: "1"
|
|
25014
|
+
},
|
|
25015
|
+
xsec_source: "pc_feed",
|
|
25016
|
+
xsec_token: params.xsec_token
|
|
25017
|
+
};
|
|
25018
|
+
const fatchFeed = "/api/sns/web/v1/feed";
|
|
25019
|
+
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
25020
|
+
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
25021
|
+
return acc;
|
|
25022
|
+
}, {});
|
|
25023
|
+
const xsHeader = xiaohongshuWebNoteFeed_xsEncrypt.signHeadersPost(fatchFeed, recordCookie, "xhs-pc-web", feedParams);
|
|
25024
|
+
const xT = Date.now().toString();
|
|
25025
|
+
const xsCommon = GenXSCommon(a1Cookie, xT, xsHeader["X-S"]);
|
|
25026
|
+
_task.logger.info(`请求参数: ${JSON.stringify(feedParams)}`);
|
|
25027
|
+
_task.logger.info(`X-S: ${xsHeader["X-S"]}`);
|
|
25028
|
+
_task.logger.info(`x-s-common: ${xsCommon}`);
|
|
25029
|
+
const res = await http.api({
|
|
25030
|
+
method: "post",
|
|
25031
|
+
url: "https://edith.xiaohongshu.com/api/sns/web/v1/feed",
|
|
25032
|
+
data: feedParams,
|
|
25033
|
+
headers: {
|
|
25034
|
+
"X-S": xsHeader["X-S"],
|
|
25035
|
+
"X-S-Common": xsCommon,
|
|
25036
|
+
"X-T": xT
|
|
25037
|
+
}
|
|
25038
|
+
}, {
|
|
25039
|
+
retries: 3,
|
|
25040
|
+
retryDelay: 20,
|
|
25041
|
+
timeout: 3000
|
|
25042
|
+
});
|
|
25043
|
+
_task.logger.info(`API 响应: ${JSON.stringify(res)}`);
|
|
25044
|
+
const isSuccess = 0 === res.code && res.data && res.data.items && res.data.items.length > 0;
|
|
25045
|
+
const message = `获取指定文章详情${isSuccess ? "成功" : `失败,原因:${res.msg || "返回数据为空,可能笔记不存在或参数错误"}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
25046
|
+
const data = isSuccess ? res.data?.items[0].note_card || {} : {};
|
|
25047
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
25048
|
+
};
|
|
25049
|
+
const xiaohongshuWebRelationAction_xsEncrypt = new Xhshow();
|
|
25050
|
+
const xiaohongshuWebRelationAction = async (_task, params)=>{
|
|
25051
|
+
if (DisabledReq) return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(414, "用户关系操作失败", {});
|
|
25052
|
+
const headers = {
|
|
25053
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
25054
|
+
referer: "https://www.xiaohongshu.com/",
|
|
25055
|
+
origin: "https://www.xiaohongshu.com/"
|
|
25056
|
+
};
|
|
25057
|
+
const args = [
|
|
25058
|
+
{
|
|
25059
|
+
headers
|
|
25060
|
+
},
|
|
25061
|
+
_task.logger,
|
|
25062
|
+
params.proxyLoc,
|
|
25063
|
+
params.localIP,
|
|
25064
|
+
params.accountId
|
|
25065
|
+
];
|
|
25066
|
+
const http = new Http(...args);
|
|
25067
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
25068
|
+
if (!a1Cookie) return {
|
|
25069
|
+
code: 414,
|
|
25070
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
25071
|
+
data: {}
|
|
25072
|
+
};
|
|
25073
|
+
if (!params.action || !params.target_user_id) return {
|
|
25074
|
+
code: 414,
|
|
25075
|
+
message: "参数缺失,请检查后重试!",
|
|
25076
|
+
data: {}
|
|
25077
|
+
};
|
|
25078
|
+
const relationParams = {
|
|
25079
|
+
target_user_id: params.target_user_id
|
|
25080
|
+
};
|
|
25081
|
+
let relationActionRes;
|
|
25082
|
+
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
25083
|
+
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
25084
|
+
return acc;
|
|
25085
|
+
}, {});
|
|
25086
|
+
switch(params.action){
|
|
25087
|
+
case "follow":
|
|
25088
|
+
{
|
|
25089
|
+
const followMentions = "/api/sns/web/v1/user/follow";
|
|
25090
|
+
const followXsHeader = xiaohongshuWebRelationAction_xsEncrypt.signHeadersPost(followMentions, recordCookie, "xhs-pc-web", relationParams);
|
|
25091
|
+
relationActionRes = await http.api({
|
|
25092
|
+
method: "post",
|
|
25093
|
+
url: "https://edith.xiaohongshu.com/api/sns/web/v1/user/follow",
|
|
25094
|
+
data: relationParams,
|
|
25095
|
+
headers: followXsHeader
|
|
25096
|
+
}, {
|
|
25097
|
+
retries: 3,
|
|
25098
|
+
retryDelay: 500,
|
|
25099
|
+
timeout: 3000
|
|
25100
|
+
});
|
|
25101
|
+
break;
|
|
25102
|
+
}
|
|
25103
|
+
case "unfollow":
|
|
25104
|
+
{
|
|
25105
|
+
const unfllowMentions = "/api/sns/web/v1/user/unfollow";
|
|
25106
|
+
const unfllowXsHeader = xiaohongshuWebRelationAction_xsEncrypt.signHeadersPost(unfllowMentions, recordCookie, "xhs-pc-web", relationParams);
|
|
25107
|
+
relationActionRes = await http.api({
|
|
25108
|
+
method: "post",
|
|
25109
|
+
url: "https://edith.xiaohongshu.com/api/sns/web/v1/user/unfollow",
|
|
25110
|
+
data: relationParams,
|
|
25111
|
+
headers: unfllowXsHeader
|
|
25112
|
+
}, {
|
|
25113
|
+
retries: 3,
|
|
25114
|
+
retryDelay: 20,
|
|
25115
|
+
timeout: 3000
|
|
25116
|
+
});
|
|
25117
|
+
break;
|
|
25118
|
+
}
|
|
25119
|
+
default:
|
|
25120
|
+
return {
|
|
25121
|
+
code: 414,
|
|
25122
|
+
message: "参数action错误,请重试!",
|
|
25123
|
+
data: {}
|
|
25124
|
+
};
|
|
25125
|
+
}
|
|
25126
|
+
const isSuccess = 0 === relationActionRes.code;
|
|
25127
|
+
const message = `用户关系操作${isSuccess ? "成功" : `失败,原因:${relationActionRes.msg}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
25128
|
+
const data = isSuccess ? relationActionRes.data : {
|
|
25129
|
+
fstatus: null
|
|
25130
|
+
};
|
|
25131
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
25132
|
+
};
|
|
25133
|
+
const xiaohongshuWebSearch_xsEncrypt = new Xhshow();
|
|
25134
|
+
const XhsWebSearchParamsSchema = ActionCommonParamsSchema.extend({
|
|
25135
|
+
keyword: schemas_string(),
|
|
25136
|
+
page: schemas_number(),
|
|
25137
|
+
page_size: schemas_number(),
|
|
25138
|
+
sort_type: schemas_enum([
|
|
25139
|
+
"general",
|
|
25140
|
+
"time_descending",
|
|
25141
|
+
"popular_descending"
|
|
25142
|
+
]),
|
|
25143
|
+
time_filter: schemas_enum([
|
|
25144
|
+
"不限",
|
|
25145
|
+
"一周内"
|
|
25146
|
+
])
|
|
25147
|
+
});
|
|
25148
|
+
const createSearchId = ()=>{
|
|
25149
|
+
let r = BigInt(Date.now());
|
|
25150
|
+
const o = BigInt(Math.ceil(0x7ffffffe * Math.random()));
|
|
25151
|
+
r <<= BigInt(64);
|
|
25152
|
+
r += o;
|
|
25153
|
+
return r.toString(36);
|
|
25154
|
+
};
|
|
25155
|
+
const xiaohongshuWebSearch = async (_task, params)=>{
|
|
25156
|
+
const headers = {
|
|
25157
|
+
cookie: params.cookies.map((it)=>`${it.name}=${it.value}`).join(";"),
|
|
25158
|
+
referer: "https://www.xiaohongshu.com/",
|
|
25159
|
+
origin: "https://www.xiaohongshu.com/"
|
|
25160
|
+
};
|
|
25161
|
+
const args = [
|
|
25162
|
+
{
|
|
25163
|
+
headers
|
|
25164
|
+
},
|
|
25165
|
+
_task.logger,
|
|
25166
|
+
params.proxyLoc,
|
|
25167
|
+
params.localIP,
|
|
25168
|
+
params.accountId
|
|
25169
|
+
];
|
|
25170
|
+
const http = new Http(...args);
|
|
25171
|
+
const a1Cookie = params.cookies.find((it)=>"a1" === it.name)?.value;
|
|
25172
|
+
if (!a1Cookie) return {
|
|
25173
|
+
code: 414,
|
|
25174
|
+
message: "账号数据异常,请重新绑定账号后重试。",
|
|
25175
|
+
data: {}
|
|
25176
|
+
};
|
|
25177
|
+
if (!params.keyword || !params.page || !params.page_size || !params.sort_type || !params.time_filter) {
|
|
25178
|
+
if ("general" !== params.sort_type && "time_descending" !== params.sort_type && "popular_descending" !== params.sort_type) return {
|
|
25179
|
+
code: 414,
|
|
25180
|
+
message: "排序类型参数错误,请检查后重试!",
|
|
25181
|
+
data: {}
|
|
25182
|
+
};
|
|
25183
|
+
if ("不限" !== params.time_filter && "一周内" !== params.time_filter) return {
|
|
25184
|
+
code: 414,
|
|
25185
|
+
message: "时间过滤参数错误,请检查后重试!",
|
|
25186
|
+
data: {}
|
|
25187
|
+
};
|
|
25188
|
+
return {
|
|
25189
|
+
code: 414,
|
|
25190
|
+
message: "参数缺失,请检查后重试!",
|
|
25191
|
+
data: {}
|
|
25192
|
+
};
|
|
25193
|
+
}
|
|
25194
|
+
const filterPath = "/api/sns/web/v1/search/notes";
|
|
25195
|
+
const filterParams = {
|
|
25196
|
+
ext_flags: [],
|
|
25197
|
+
geo: "",
|
|
25198
|
+
image_formats: [
|
|
25199
|
+
"jpg",
|
|
25200
|
+
"webp",
|
|
25201
|
+
"avif"
|
|
25202
|
+
],
|
|
25203
|
+
filters: [
|
|
25204
|
+
{
|
|
25205
|
+
tags: [
|
|
25206
|
+
params.sort_type
|
|
25207
|
+
],
|
|
25208
|
+
type: "sort_type"
|
|
25209
|
+
},
|
|
25210
|
+
{
|
|
25211
|
+
tags: [
|
|
25212
|
+
"不限"
|
|
25213
|
+
],
|
|
25214
|
+
type: "filter_note_type"
|
|
25215
|
+
},
|
|
25216
|
+
{
|
|
25217
|
+
tags: [
|
|
25218
|
+
params.time_filter
|
|
25219
|
+
],
|
|
25220
|
+
type: "filter_note_time"
|
|
25221
|
+
},
|
|
25222
|
+
{
|
|
25223
|
+
tags: [
|
|
25224
|
+
"不限"
|
|
25225
|
+
],
|
|
25226
|
+
type: "filter_note_range"
|
|
25227
|
+
},
|
|
25228
|
+
{
|
|
25229
|
+
tags: [
|
|
25230
|
+
"不限"
|
|
25231
|
+
],
|
|
25232
|
+
type: "filter_pos_distance"
|
|
25233
|
+
}
|
|
25234
|
+
],
|
|
25235
|
+
keyword: params.keyword,
|
|
25236
|
+
note_type: 0,
|
|
25237
|
+
page: params.page,
|
|
25238
|
+
page_size: params.page_size,
|
|
25239
|
+
search_id: createSearchId() + (params.sort_type || params.time_filter ? `@${createSearchId()}` : ""),
|
|
25240
|
+
sort: "general"
|
|
25241
|
+
};
|
|
25242
|
+
const recordCookie = params.cookies.reduce((acc, cookie)=>{
|
|
25243
|
+
if (cookie.name && cookie.value) acc[cookie.name] = cookie.value;
|
|
25244
|
+
return acc;
|
|
25245
|
+
}, {});
|
|
25246
|
+
const searchXsHeader = xiaohongshuWebSearch_xsEncrypt.signHeadersPost(filterPath, recordCookie, "xhs-pc-web", filterParams);
|
|
25247
|
+
const res = await http.api({
|
|
25248
|
+
method: "post",
|
|
25249
|
+
url: "https://edith.xiaohongshu.com/api/sns/web/v1/search/notes",
|
|
25250
|
+
data: filterParams,
|
|
25251
|
+
headers: searchXsHeader
|
|
25252
|
+
}, {
|
|
25253
|
+
retries: 3,
|
|
25254
|
+
retryDelay: 20,
|
|
25255
|
+
timeout: 3000
|
|
25256
|
+
});
|
|
25257
|
+
const isSuccess = 0 === res.code;
|
|
25258
|
+
const message = `Web笔记搜索${isSuccess ? "成功" : `失败,原因:${res.msg}`}${_task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
25259
|
+
const data = isSuccess ? res.data : {};
|
|
25260
|
+
return (0, __WEBPACK_EXTERNAL_MODULE__iflyrpa_share_f7afdc8c__.response)(isSuccess ? 0 : 414, message, data);
|
|
25261
|
+
};
|
|
25262
|
+
const ttConfigDataSchema = schemas_object({
|
|
25263
|
+
fansNum: schemas_number(),
|
|
25264
|
+
fansNumYesterday: schemas_number().nullable(),
|
|
25265
|
+
readNum: schemas_number(),
|
|
25266
|
+
incomeNum: schemas_number(),
|
|
25267
|
+
incomeNumYesterday: schemas_number().nullable(),
|
|
25268
|
+
showNumYesterday: schemas_number().nullable(),
|
|
25269
|
+
readNumYesterday: schemas_number().nullable(),
|
|
25270
|
+
likeNumYesterday: schemas_number().nullable(),
|
|
25271
|
+
commentNumYesterday: schemas_number().nullable()
|
|
25272
|
+
});
|
|
25273
|
+
const xhsConfigDataSchema = schemas_object({
|
|
25274
|
+
fansNum: schemas_number(),
|
|
25275
|
+
favedNum: schemas_number(),
|
|
25276
|
+
watchNumLastWeek: schemas_number(),
|
|
25277
|
+
likeNumLastWeek: schemas_number(),
|
|
25278
|
+
collectNumLastWeek: schemas_number(),
|
|
25279
|
+
commentNumLastWeek: schemas_number(),
|
|
25280
|
+
fansNumLastWeek: schemas_number(),
|
|
25281
|
+
fansNumYesterday: schemas_number()
|
|
25282
|
+
});
|
|
25283
|
+
const wxConfigDataSchema = schemas_object({
|
|
25284
|
+
fansNum: schemas_number(),
|
|
25285
|
+
fansNumYesterday: schemas_number(),
|
|
25286
|
+
readNumYesterday: schemas_number(),
|
|
25287
|
+
shareNumYesterday: schemas_number()
|
|
25288
|
+
});
|
|
25289
|
+
const bjhConfigDataSchema = schemas_object({
|
|
25290
|
+
fansNum: schemas_number(),
|
|
25291
|
+
fansNumYesterday: schemas_number().nullable(),
|
|
25292
|
+
readNum: schemas_number(),
|
|
25293
|
+
incomeNum: schemas_number(),
|
|
25294
|
+
incomeNumYesterday: schemas_number().nullable(),
|
|
25295
|
+
recommendNumYesterday: schemas_number().nullable(),
|
|
25296
|
+
readNumYesterday: schemas_number().nullable(),
|
|
25297
|
+
likeNumYesterday: schemas_number().nullable(),
|
|
25298
|
+
commentNumYesterday: schemas_number().nullable()
|
|
25299
|
+
});
|
|
24308
25300
|
const BetaFlag = "HuiwenCanary";
|
|
24309
25301
|
class Action {
|
|
24310
25302
|
constructor(task){
|