Showing
1 changed file
with
9 additions
and
2 deletions
| @@ -13,7 +13,7 @@ from openpyxl.styles import Alignment, Font, PatternFill | @@ -13,7 +13,7 @@ from openpyxl.styles import Alignment, Font, PatternFill | ||
| 13 | from .errors import NoFeedDetailError, PageNotAccessibleError, XHSError | 13 | from .errors import NoFeedDetailError, PageNotAccessibleError, XHSError |
| 14 | from .feed_detail import get_feed_detail | 14 | from .feed_detail import get_feed_detail |
| 15 | from .search import search_feeds | 15 | from .search import search_feeds |
| 16 | -from .types import Comment, Feed, FilterOption | 16 | +from .types import Comment, CommentLoadConfig, Feed, FilterOption |
| 17 | 17 | ||
| 18 | logger = logging.getLogger(__name__) | 18 | logger = logging.getLogger(__name__) |
| 19 | 19 | ||
| @@ -326,6 +326,7 @@ def poll_comments( | @@ -326,6 +326,7 @@ def poll_comments( | ||
| 326 | excel_file: str, | 326 | excel_file: str, |
| 327 | feed_index: int | None = None, | 327 | feed_index: int | None = None, |
| 328 | delay: float = 1.0, | 328 | delay: float = 1.0, |
| 329 | + config: CommentLoadConfig | None = None, | ||
| 329 | ) -> dict: | 330 | ) -> dict: |
| 330 | """轮询查询评论并保存到 Excel。 | 331 | """轮询查询评论并保存到 Excel。 |
| 331 | 332 | ||
| @@ -343,6 +344,12 @@ def poll_comments( | @@ -343,6 +344,12 @@ def poll_comments( | ||
| 343 | if not export.load(): | 344 | if not export.load(): |
| 344 | raise FileNotFoundError(f"Excel 文件不存在: {excel_file}") | 345 | raise FileNotFoundError(f"Excel 文件不存在: {excel_file}") |
| 345 | 346 | ||
| 347 | + if config is None: | ||
| 348 | + config = CommentLoadConfig( | ||
| 349 | + click_more_replies=True, | ||
| 350 | + max_comment_items=0, | ||
| 351 | + ) | ||
| 352 | + | ||
| 346 | pending_feeds = export.get_pending_feeds() | 353 | pending_feeds = export.get_pending_feeds() |
| 347 | 354 | ||
| 348 | if feed_index is not None: | 355 | if feed_index is not None: |
| @@ -380,7 +387,7 @@ def poll_comments( | @@ -380,7 +387,7 @@ def poll_comments( | ||
| 380 | 387 | ||
| 381 | try: | 388 | try: |
| 382 | # 获取文章详情(含评论) | 389 | # 获取文章详情(含评论) |
| 383 | - detail = get_feed_detail(page, feed_id, xsec_token, load_all_comments=True) | 390 | + detail = get_feed_detail(page, feed_id, xsec_token, load_all_comments=True, config=config) |
| 384 | 391 | ||
| 385 | # 保存评论 | 392 | # 保存评论 |
| 386 | for comment in detail.comments.list_: | 393 | for comment in detail.comments.list_: |
-
Please register or login to post a comment