Toggle navigation
Toggle navigation
This project
Loading...
Sign in
顾海波
/
xiaohongshu-skills
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
顾海波
2026-04-01 16:14:01 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6c036053f234e3a2eae427c70e3990a7a901d1a2
6c036053
1 parent
8dc3e081
【需求】导出更多评论
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
scripts/xhs/export_excel.py
scripts/xhs/export_excel.py
View file @
6c03605
...
...
@@ -13,7 +13,7 @@ from openpyxl.styles import Alignment, Font, PatternFill
from
.errors
import
NoFeedDetailError
,
PageNotAccessibleError
,
XHSError
from
.feed_detail
import
get_feed_detail
from
.search
import
search_feeds
from
.types
import
Comment
,
Feed
,
FilterOption
from
.types
import
Comment
,
CommentLoadConfig
,
Feed
,
FilterOption
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -326,6 +326,7 @@ def poll_comments(
excel_file
:
str
,
feed_index
:
int
|
None
=
None
,
delay
:
float
=
1.0
,
config
:
CommentLoadConfig
|
None
=
None
,
)
->
dict
:
"""轮询查询评论并保存到 Excel。
...
...
@@ -343,6 +344,12 @@ def poll_comments(
if
not
export
.
load
():
raise
FileNotFoundError
(
f
"Excel 文件不存在: {excel_file}"
)
if
config
is
None
:
config
=
CommentLoadConfig
(
click_more_replies
=
True
,
max_comment_items
=
0
,
)
pending_feeds
=
export
.
get_pending_feeds
()
if
feed_index
is
not
None
:
...
...
@@ -380,7 +387,7 @@ def poll_comments(
try
:
# 获取文章详情(含评论)
detail
=
get_feed_detail
(
page
,
feed_id
,
xsec_token
,
load_all_comments
=
True
)
detail
=
get_feed_detail
(
page
,
feed_id
,
xsec_token
,
load_all_comments
=
True
,
config
=
config
)
# 保存评论
for
comment
in
detail
.
comments
.
list_
:
...
...
Please
register
or
login
to post a comment