tt-help-cli-ycl 1.4.46 → 1.4.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-help-cli-ycl",
3
- "version": "1.4.46",
3
+ "version": "1.4.48",
4
4
  "description": "TikTok user & video data scraper - extract ttSeller, verified, locationCreated from HTML source",
5
5
  "type": "module",
6
6
  "bin": {
@@ -83,7 +83,7 @@ function extractJsonByKey(html, keyPattern) {
83
83
 
84
84
  /**
85
85
  * Windows: 后台服务的 Playwright 浏览器在 Session 0(隔离桌面),
86
- * RDP 看不到。找到交互桌面 Session,用计划任务推到那个 Session。
86
+ * RDP 看不到。用计划任务推到交互桌面(/it 自动定位已登录用户,无需密码)。
87
87
  */
88
88
  let winRecoveryRunning = false;
89
89
 
@@ -98,42 +98,40 @@ async function resolveCaptchaWindows(url, proxyUrl) {
98
98
  const edgeUrl = url.replace("shop.tiktok.com", "www.tiktok.com/shop/pdp");
99
99
  const taskName = "TikTokCaptchaRecovery";
100
100
 
101
- // 1. 找到交互桌面 Session
102
- let sessionId = null;
101
+ // 1. 用计划任务推到交互桌面(/it 自动定位已登录用户)
102
+ let taskCreated = false;
103
103
  try {
104
- const sessions = execSync(
105
- `powershell -NoProfile -Command "query session 2>$null | Select-String 'Active' | ForEach-Object { \\$_.Line }"`,
106
- { shell: "cmd.exe", timeout: 5000, encoding: "utf-8" },
107
- );
108
- const lines = sessions.trim().split("\n");
109
- for (const line of lines) {
110
- const match = line.match(/>\s*(\d+)\s/);
111
- if (match && match[1] !== "0") {
112
- sessionId = parseInt(match[1], 10);
113
- break;
114
- }
115
- }
116
- } catch {
117
- console.error("[shop-scraper] Windows: 无法获取交互 Session");
118
- }
119
-
120
- if (sessionId) {
121
- console.error(
122
- `[shop-scraper] Windows: Session ${sessionId},用计划任务启动 Edge`,
123
- );
104
+ // 清理旧任务
124
105
  try {
125
106
  execSync(`schtasks /delete /tn "${taskName}" /f 2>$null`, {
126
107
  shell: "cmd.exe",
127
108
  });
128
109
  } catch {}
110
+
111
+ // 获取当天日期,格式 yyyy/MM/dd
112
+ const today = execSync(
113
+ `powershell -NoProfile -Command "Get-Date -Format yyyy/MM/dd"`,
114
+ { shell: "cmd.exe", timeout: 3000, encoding: "utf-8" },
115
+ ).trim();
116
+
129
117
  execSync(
130
- `schtasks /create /tn "${taskName}" /tr "msedge ${edgeUrl}" /sc once /st 00:00 /it /f`,
118
+ `schtasks /create /tn "${taskName}" /tr "msedge \\"${edgeUrl}\\"" /sc once /sd ${today} /st 23:59 /it /f`,
131
119
  { shell: "cmd.exe", timeout: 10000 },
132
120
  );
133
121
  execSync(`schtasks /run /tn "${taskName}"`, {
134
122
  shell: "cmd.exe",
135
123
  timeout: 10000,
136
124
  });
125
+ taskCreated = true;
126
+ console.error(
127
+ "[shop-scraper] Windows: 计划任务已启动 Edge,请在 RDP 中完成验证码",
128
+ );
129
+ } catch (e) {
130
+ console.error("[shop-scraper] Windows: 计划任务失败:", e.message);
131
+ }
132
+
133
+ // 延迟删除任务
134
+ if (taskCreated) {
137
135
  setTimeout(() => {
138
136
  try {
139
137
  execSync(`schtasks /delete /tn "${taskName}" /f 2>$null`, {
@@ -141,16 +139,6 @@ async function resolveCaptchaWindows(url, proxyUrl) {
141
139
  });
142
140
  } catch {}
143
141
  }, 10000);
144
- } else {
145
- console.error(
146
- "[shop-scraper] Windows: 未找到交互 Session,尝试直接 start",
147
- );
148
- try {
149
- execSync(`start "" "microsoft-edge:${edgeUrl}"`, {
150
- shell: "cmd.exe",
151
- timeout: 5000,
152
- });
153
- } catch {}
154
142
  }
155
143
 
156
144
  // 2. 轮询 undici 等待 IP 信用恢复