|
|
@@ -960,22 +960,19 @@ class HeadlessBrowserService {
|
|
|
const hasNextCursor = next !== undefined && next !== null && next !== '' && next !== -1 && next !== '-1';
|
|
|
|
|
|
if (hasNextCursor) {
|
|
|
- const key = String(next);
|
|
|
+ const key = String(next).trim();
|
|
|
if (seenCursors.has(key)) break;
|
|
|
seenCursors.add(key);
|
|
|
cursor = next;
|
|
|
} else {
|
|
|
- if (platform === 'douyin') break;
|
|
|
cursor = (typeof cursor === 'number' ? cursor + 1 : pageIndex + 1);
|
|
|
}
|
|
|
|
|
|
- // 抖音:仅当无下一页游标或本页 0 条时停止
|
|
|
- if (platform === 'douyin') {
|
|
|
- if (!hasNextCursor || pageWorks.length === 0) break;
|
|
|
- } else {
|
|
|
- const expectedMore = declaredTotal && declaredTotal > 0 ? allWorks.length < declaredTotal : !!result.has_more;
|
|
|
- if (!expectedMore || pageWorks.length === 0 || newCount === 0) break;
|
|
|
- }
|
|
|
+ // 仅当无下一页游标或本页 0 条时停止
|
|
|
+ if (!hasNextCursor || pageWorks.length === 0) break;
|
|
|
+
|
|
|
+ // 额外检查:若已达声明总量则停止
|
|
|
+ if (declaredTotal && declaredTotal > 0 && allWorks.length >= declaredTotal) break;
|
|
|
} else {
|
|
|
if (!result.has_more || pageWorks.length === 0 || newCount === 0) break;
|
|
|
}
|