Skip to content

Commit

Permalink
When the query has no content, terminate the loop early
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasonyang2014 committed Jul 18, 2024
1 parent 548271e commit 1fd7827
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions media_platform/xhs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ async def search(self) -> None:
sort=SearchSortType(config.SORT_TYPE) if config.SORT_TYPE != '' else SearchSortType.GENERAL,
)
utils.logger.info(f"[XiaoHongShuCrawler.search] Search notes res:{notes_res}")
if(not notes_res or not notes_res.get('has_more', False)):
utils.logger.info("No more content!")
break
semaphore = asyncio.Semaphore(config.MAX_CONCURRENCY_NUM)
task_list = [
self.get_note_detail(post_item.get("id"), semaphore)
Expand Down

0 comments on commit 1fd7827

Please sign in to comment.