Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[提问] get_comments方法不能获取到完全体子评论(?) #876

Open
Sonab03 opened this issue Jan 7, 2025 · 0 comments
Open
Labels
question 这啥呀这是,我不到啊

Comments

@Sonab03
Copy link

Sonab03 commented Jan 7, 2025

Python 版本: 3.12.2

模块版本: 16.3.0

运行环境: MacOS


大佬们2025快乐!

虽然能正常跑通,但还是有些不知道算不算问题的问题,如下:

  1. 使用async def get_comments()方法时,默认输出的虽然仅为主评论,但count的时候会将所有 (疑似还包含已删除的) 子评论全部计入

栗子🌰:b站显示37条,count提示40条,实际默认收集输出14条

  1. 在如下所示魔改了一下,以妄图将所有评论收入囊中时:
def flatten_comment(comment):
    # 展平单个评论
    flattened_comment = {
        "uname": comment["member"]["uname"],
        "message": comment["content"]["message"],
        "like": comment["like"],
        "ctime": comment["ctime"],
        "IP location": comment['reply_control']['location']
    }
    return flattened_comment

def extract_comments(comments):
    # 提取所有评论,包括子评论
    all_comments = []
    for comment in comments:
        all_comments.append(flatten_comment(comment))
        if "replies" in comment and comment["replies"]:
            all_comments.extend(extract_comments(comment["replies"]))
    return all_comments

发现,大部分子评论可以收集,但少数类似这种回复已被删除或者不蓝了的回复就无法收集到。鉴于目前b站阿瓦隆经常吞人回复,所以有的视频下这种虚空索敌的评论还挺多,收集不到有些可惜TT。
image

如上两个问题,期待大佬们的解答,还有感谢大佬们的贡献,先给大家磕一个Orz

@Sonab03 Sonab03 added the question 这啥呀这是,我不到啊 label Jan 7, 2025
@Sonab03 Sonab03 changed the title [提问] 这里填写标题 [提问] get_comments Jan 7, 2025
@Sonab03 Sonab03 changed the title [提问] get_comments [提问] get_comments方法不能获取到完全体子评论(?) Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question 这啥呀这是,我不到啊
Projects
None yet
Development

No branches or pull requests

1 participant