Browse Source

fix: 搜不到文章时需要暂停

wuwenyi 8 months ago
parent
commit
4ff7b6abaf
1 changed files with 3 additions and 0 deletions
  1. 3 0
      huitun/__init__.py

+ 3 - 0
huitun/__init__.py

@@ -41,6 +41,7 @@ class HuiTunBrowser(BaseBrowser):
         try:
             self.__init_browser__()
             self.list_result = []
+            self.has_more = True
             api.assert_not_none(tag_name, "标签不能为空")
             self.page.goto('https://xhs.huitun.com/#/note/note_search')
             # 展开全部标签
@@ -55,6 +56,8 @@ class HuiTunBrowser(BaseBrowser):
                 self.page.evaluate("window.scrollTo(0, document.body.scrollHeight)")
                 self.page.wait_for_timeout(2000)
                 logging.info('搜索用户主页图文结果数:%s', len(self.list_result))
+                if not self.has_more:
+                    break
             return self.list_result
         finally:
             lock_manager.release_lock(self.phone)