tt-help-cli-ycl 1.4.48 → 1.4.50

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.48",
3
+ "version": "1.4.50",
4
4
  "description": "TikTok user & video data scraper - extract ttSeller, verified, locationCreated from HTML source",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,6 @@
17
17
  */
18
18
 
19
19
  import { ProxyAgent, request } from "undici";
20
- import { execSync } from "child_process";
21
20
  import { DEFAULT_PROXY } from "./constants.js";
22
21
 
23
22
  const PDP_HEADERS = {
@@ -81,104 +80,6 @@ function extractJsonByKey(html, keyPattern) {
81
80
  return null;
82
81
  }
83
82
 
84
- /**
85
- * Windows: 后台服务的 Playwright 浏览器在 Session 0(隔离桌面),
86
- * RDP 看不到。用计划任务推到交互桌面(/it 自动定位已登录用户,无需密码)。
87
- */
88
- let winRecoveryRunning = false;
89
-
90
- async function resolveCaptchaWindows(url, proxyUrl) {
91
- if (winRecoveryRunning) {
92
- console.error("[shop-scraper] Windows: 验证码恢复已在运行,跳过");
93
- return false;
94
- }
95
- winRecoveryRunning = true;
96
-
97
- try {
98
- const edgeUrl = url.replace("shop.tiktok.com", "www.tiktok.com/shop/pdp");
99
- const taskName = "TikTokCaptchaRecovery";
100
-
101
- // 1. 用计划任务推到交互桌面(/it 自动定位已登录用户)
102
- let taskCreated = false;
103
- try {
104
- // 清理旧任务
105
- try {
106
- execSync(`schtasks /delete /tn "${taskName}" /f 2>$null`, {
107
- shell: "cmd.exe",
108
- });
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
-
117
- execSync(
118
- `schtasks /create /tn "${taskName}" /tr "msedge \\"${edgeUrl}\\"" /sc once /sd ${today} /st 23:59 /it /f`,
119
- { shell: "cmd.exe", timeout: 10000 },
120
- );
121
- execSync(`schtasks /run /tn "${taskName}"`, {
122
- shell: "cmd.exe",
123
- timeout: 10000,
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) {
135
- setTimeout(() => {
136
- try {
137
- execSync(`schtasks /delete /tn "${taskName}" /f 2>$null`, {
138
- shell: "cmd.exe",
139
- });
140
- } catch {}
141
- }, 10000);
142
- }
143
-
144
- // 2. 轮询 undici 等待 IP 信用恢复
145
- const proxy = proxyUrl || DEFAULT_PROXY;
146
- const agent = proxy ? new ProxyAgent(proxy) : null;
147
- const POLL_MS = 5000;
148
- const MAX_WAIT_MS = 3600_000;
149
- const startTime = Date.now();
150
-
151
- while (Date.now() - startTime < MAX_WAIT_MS) {
152
- await new Promise((r) => setTimeout(r, POLL_MS));
153
- try {
154
- const { body } = await request(url, {
155
- headers: PDP_HEADERS,
156
- ...(agent ? { dispatcher: agent } : {}),
157
- });
158
- const html = await body.text();
159
- if (
160
- html.includes('"product_model"') ||
161
- html.includes('"review_ratings"')
162
- ) {
163
- console.error("[shop-scraper] Captcha solved, IP credit restored");
164
- return true;
165
- }
166
- } catch {}
167
- const waited = Math.round((Date.now() - startTime) / 60000);
168
- if (waited > 0 && waited % 5 === 0) {
169
- console.error(
170
- `[shop-scraper] 等待验证码解决中... 已等待 ${waited} 分钟`,
171
- );
172
- }
173
- }
174
-
175
- console.error("[shop-scraper] Windows: 等待验证码超时");
176
- return false;
177
- } finally {
178
- winRecoveryRunning = false;
179
- }
180
- }
181
-
182
83
  /**
183
84
  * Open a headed browser for manual captcha solving, extract cookies
184
85
  * so undici can reuse them for a while.
@@ -189,12 +90,6 @@ async function resolveCaptchaWindows(url, proxyUrl) {
189
90
  export async function resolveCaptchaWithBrowser(url, proxyUrl) {
190
91
  const { chromium } = await import("playwright");
191
92
 
192
- // Windows 后台服务启动的浏览器在 Session 0,RDP 看不到。
193
- // 用 start 命令推到当前交互桌面。
194
- if (process.platform === "win32") {
195
- return resolveCaptchaWindows(url, proxyUrl);
196
- }
197
-
198
93
  const args = ["--no-sandbox"];
199
94
  if (proxyUrl) {
200
95
  args.push(`--proxy-server=${proxyUrl.replace("http://", "http://")}`);