From 6313631b09ff8e3ba80e48b5aeae865094835ccc Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Wed, 14 Jan 2026 13:17:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=B9=E8=BF=9B=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E7=A1=AE=E4=BF=9D=E9=81=8D=E5=8E=86?= =?UTF-8?q?=E6=89=80=E6=9C=89=E9=A1=B5=E9=9D=A2=E4=B8=8D=E6=BC=8F=E6=8E=89?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 当前页有新文章时,重新获取第1页(已读文章消失后页面上移) - 当前页无新文章时,继续检查后续页面 - 遍历完所有页面后才结束循环 - 解决 mark_read 延迟导致后续页面内容被漏掉的问题 Co-Authored-By: Claude Opus 4.5 --- api_browser.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/api_browser.py b/api_browser.py index de96912..21d75b7 100755 --- a/api_browser.py +++ b/api_browser.py @@ -471,11 +471,11 @@ class APIBrowser: report_progress(force=True) - # 循环处理:每次获取第1页,直到没有内容 - # 这样可以避免分页错位问题(标记已读后文章从列表消失导致后续页面上移) - max_iterations = total_records + 10 # 防止无限循环 + # 循环处理:遍历所有页面,跟踪已处理文章防止重复 + max_iterations = total_records + 20 # 防止无限循环 iteration = 0 processed_hrefs = set() # 跟踪已处理的文章,防止重复处理 + current_page = 1 while articles and iteration < max_iterations: iteration += 1 @@ -525,18 +525,25 @@ class APIBrowser: time.sleep(0.1) - # 如果当前页没有新文章被处理,说明所有文章都已处理过,退出循环 - if new_articles_in_page == 0: - self.log(f"[API] 当前页所有文章均已处理,结束循环") - break - time.sleep(0.2) - # 重新获取第1页,检查是否还有未处理的内容 + # 决定下一步获取哪一页 + if new_articles_in_page > 0: + # 有新文章被处理,重新获取第1页(因为已读文章会从列表消失,页面会上移) + current_page = 1 + else: + # 当前页没有新文章,尝试下一页 + current_page += 1 + if current_page > total_pages: + self.log(f"[API] 已遍历所有 {total_pages} 页,结束循环") + break + try: - articles, _, _ = self.get_article_list_page(bz, 1) + articles, new_total_pages, _ = self.get_article_list_page(bz, current_page) + if new_total_pages > 0: + total_pages = new_total_pages except Exception as e: - self.log(f"[API] 重新获取列表失败: {str(e)}") + self.log(f"[API] 获取第{current_page}页列表失败: {str(e)}") break report_progress(force=True)