diff --git a/backServer/capture.js b/backServer/capture.js index d3bc295..711343b 100644 --- a/backServer/capture.js +++ b/backServer/capture.js @@ -1,4 +1,5 @@ import { chromium } from 'playwright' +import readlineSync from 'readline-sync' import { ensureDataFiles, readCache, writeCache, writeStatus } from './lib/cache.js' const PAGE_URL = 'https://www1.gdtv.cn/tvColumn/768' @@ -73,10 +74,7 @@ async function getPageScrollInfo(page) { return await page.evaluate(() => { return { scrollTop: window.scrollY || document.documentElement.scrollTop || document.body.scrollTop || 0, - scrollHeight: Math.max( - document.body.scrollHeight, - document.documentElement.scrollHeight - ), + scrollHeight: Math.max(document.body.scrollHeight, document.documentElement.scrollHeight), innerHeight: window.innerHeight } }) @@ -153,7 +151,12 @@ async function clickLoadMoreAndWait(page) { return !!response } -async function autoCollectByScrollAndClick(page, maxRounds = 120) { +function askContinue() { + const answer = readlineSync.question('\n页面已滑到底部,继续采集吗?(y/n): ') + return answer.trim().toLowerCase() === 'y' +} + +async function autoCollectByScrollAndClick(page, maxRounds = 150) { let round = 0 let noChangeRounds = 0 let lastDomCount = await getDomItemCount(page) @@ -214,14 +217,30 @@ async function autoCollectByScrollAndClick(page, maxRounds = 120) { await sleep(1800) const retryButton = await findLoadMoreButton(page) - if (!retryButton) { - noChangeRounds += 1 + if (retryButton) { + log('到底部后重新检测到“加载更多”按钮,继续点击') + continue } + + const shouldContinue = askContinue() + if (!shouldContinue) { + log('你选择结束采集') + break + } + + log('你选择继续采集,尝试再次下滑检测') + noChangeRounds = 0 + await sleep(1000) } if (noChangeRounds >= 6) { - log('连续多轮没有新内容,停止采集') - break + const shouldContinue = askContinue() + if (!shouldContinue) { + log('连续多轮没有新内容,且你选择结束采集') + break + } + log('你选择继续采集,重置无变化计数') + noChangeRounds = 0 } } diff --git a/backServer/data/capture-status.json b/backServer/data/capture-status.json index c2d4e30..6918fc2 100644 --- a/backServer/data/capture-status.json +++ b/backServer/data/capture-status.json @@ -1,7 +1,5 @@ { - "running": true, - "lastMessage": "已采集第 2 页", - "updatedAt": "2026-03-10T19:14:36.004Z", - "capturedPages": 26, - "totalItems": 1141 + "running": false, + "lastMessage": "自动采集完成", + "updatedAt": "2026-03-10T19:27:40.184Z" } \ No newline at end of file diff --git a/backServer/data/qishier-cache.json b/backServer/data/qishier-cache.json index 3334774..bdeca06 100644 --- a/backServer/data/qishier-cache.json +++ b/backServer/data/qishier-cache.json @@ -1,170 +1,170 @@ { - "updatedAt": "2026-03-10T19:14:35.996Z", + "updatedAt": "2026-03-10T19:27:32.690Z", "name": "七十二家房客", "coverUrl": "https://p2-grtn.itouchtv.cn/image/20191010/0.15048946623517580e4543e24e68e4824OSS1570677193.jpg", "displayType": 0, "pages": { "1": { "currentPage": 1, - "beginScore": 1669824000000, + "beginScore": 1730390400000, "count": 40, - "capturedAt": "2026-03-10T19:13:55.281Z" + "capturedAt": "2026-03-10T19:27:28.717Z" }, "2": { "currentPage": 2, - "beginScore": 1669824000000, - "count": 40, - "capturedAt": "2026-03-10T19:14:35.996Z" + "beginScore": 1730390400000, + "count": 20, + "capturedAt": "2026-03-10T19:27:31.309Z" }, "3": { "currentPage": 3, - "beginScore": 1701360000000, + "beginScore": 1730390400000, "count": 0, - "capturedAt": "2026-03-10T19:13:21.335Z" + "capturedAt": "2026-03-10T19:27:32.690Z" }, "4": { "currentPage": 4, "beginScore": 1763561820000, "count": 40, - "capturedAt": "2026-03-10T19:11:26.676Z" + "capturedAt": "2026-03-10T19:25:11.140Z" }, "5": { "currentPage": 5, "beginScore": 1762962000000, "count": 40, - "capturedAt": "2026-03-10T19:11:29.024Z" + "capturedAt": "2026-03-10T19:25:13.417Z" }, "6": { "currentPage": 6, "beginScore": 1762352220000, "count": 40, - "capturedAt": "2026-03-10T19:11:33.591Z" + "capturedAt": "2026-03-10T19:25:18.001Z" }, "7": { "currentPage": 7, "beginScore": 1761746220000, "count": 40, - "capturedAt": "2026-03-10T19:11:36.420Z" + "capturedAt": "2026-03-10T19:25:20.845Z" }, "8": { "currentPage": 8, "beginScore": 1761056280000, "count": 40, - "capturedAt": "2026-03-10T19:11:39.251Z" + "capturedAt": "2026-03-10T19:25:23.655Z" }, "9": { "currentPage": 9, "beginScore": 1740315600000, "count": 40, - "capturedAt": "2026-03-10T19:11:41.578Z" + "capturedAt": "2026-03-10T19:25:26.285Z" }, "10": { "currentPage": 10, "beginScore": 1738414800000, "count": 40, - "capturedAt": "2026-03-10T19:11:44.739Z" + "capturedAt": "2026-03-10T19:25:29.425Z" }, "11": { "currentPage": 11, "beginScore": 1736514000000, "count": 40, - "capturedAt": "2026-03-10T19:11:47.585Z" + "capturedAt": "2026-03-10T19:25:32.213Z" }, "12": { "currentPage": 12, "beginScore": 1734526800000, "count": 40, - "capturedAt": "2026-03-10T19:11:50.449Z" + "capturedAt": "2026-03-10T19:25:35.060Z" }, "13": { "currentPage": 13, "beginScore": 1732714295000, "count": 40, - "capturedAt": "2026-03-10T19:11:52.794Z" + "capturedAt": "2026-03-10T19:25:37.402Z" }, "14": { "currentPage": 14, "beginScore": 1730986358000, "count": 40, - "capturedAt": "2026-03-10T19:11:57.376Z" + "capturedAt": "2026-03-10T19:25:42.036Z" }, "15": { "currentPage": 15, "beginScore": 1729171974000, "count": 40, - "capturedAt": "2026-03-10T19:12:00.272Z" + "capturedAt": "2026-03-10T19:25:44.872Z" }, "16": { "currentPage": 16, "beginScore": 1727442000000, "count": 40, - "capturedAt": "2026-03-10T19:12:03.129Z" + "capturedAt": "2026-03-10T19:25:47.704Z" }, "17": { "currentPage": 17, "beginScore": 1725713999999, "count": 40, - "capturedAt": "2026-03-10T19:12:05.452Z" + "capturedAt": "2026-03-10T19:25:50.068Z" }, "18": { "currentPage": 18, "beginScore": 1723899600000, "count": 40, - "capturedAt": "2026-03-10T19:12:10.101Z" + "capturedAt": "2026-03-10T19:25:54.781Z" }, "19": { "currentPage": 19, "beginScore": 1721998800000, "count": 40, - "capturedAt": "2026-03-10T19:12:12.989Z" + "capturedAt": "2026-03-10T19:25:57.635Z" }, "20": { "currentPage": 20, "beginScore": 1720186339000, "count": 40, - "capturedAt": "2026-03-10T19:12:15.860Z" + "capturedAt": "2026-03-10T19:26:00.455Z" }, "21": { "currentPage": 21, "beginScore": 1718371929000, "count": 40, - "capturedAt": "2026-03-10T19:12:18.172Z" + "capturedAt": "2026-03-10T19:26:02.811Z" }, "22": { "currentPage": 22, "beginScore": 1716641999999, "count": 40, - "capturedAt": "2026-03-10T19:12:21.399Z" + "capturedAt": "2026-03-10T19:26:06.118Z" }, "23": { "currentPage": 23, "beginScore": 1714827600000, "count": 40, - "capturedAt": "2026-03-10T19:12:24.238Z" + "capturedAt": "2026-03-10T19:26:08.954Z" }, "24": { "currentPage": 24, "beginScore": 1713099599999, "count": 40, - "capturedAt": "2026-03-10T19:12:27.289Z" + "capturedAt": "2026-03-10T19:26:11.917Z" }, "25": { "currentPage": 25, "beginScore": 1711372007000, "count": 40, - "capturedAt": "2026-03-10T19:12:29.500Z" + "capturedAt": "2026-03-10T19:26:14.215Z" }, "26": { "currentPage": 26, "beginScore": 1709559052000, "count": 0, - "capturedAt": "2026-03-10T19:12:34.177Z" + "capturedAt": "2026-03-10T19:26:19.076Z" } }, "beginScoreMap": { - "1": 1669824000000, - "2": 1669824000000, - "3": 1701360000000, + "1": 1730390400000, + "2": 1730390400000, + "3": 1730390400000, "4": 1763561820000, "5": 1762962000000, "6": 1762352220000, diff --git a/src/views/QishierPlayer.vue b/src/views/QishierPlayer.vue index 73a3d16..cc26319 100644 --- a/src/views/QishierPlayer.vue +++ b/src/views/QishierPlayer.vue @@ -1,9 +1,15 @@