mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-07-24 05:10:30 +08:00
- 用户 ID 转为匿名 creator_hash,昵称中间脱敏,IP/头像/主页/签名/性别不再采集 - 覆盖 xhs/weibo/bilibili/douyin/kuaishou/tieba/zhihu 7 个平台 - 删除 7 张 creator 档案 ORM 表,15 张内容/评论表新增 creator_hash 列 - B 站禁用粉丝/关注/联系人列表抓取 - 新增 tools/user_hash.py 与 4 个平台的 mock+SQLite 端到端测试 测试: pytest tests/test_no_user_info.py tests/test_weibo_no_user_info.py tests/test_douyin_no_user_info.py tests/test_kuaishou_no_user_info.py (21 passed)
77 lines
3.7 KiB
Python
77 lines
3.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright (c) 2025 relakkes@gmail.com
|
|
#
|
|
# This file is part of MediaCrawler project.
|
|
# Repository: https://github.com/NanmiCoder/MediaCrawler/blob/main/model/m_zhihu.py
|
|
# GitHub: https://github.com/NanmiCoder
|
|
# Licensed under NON-COMMERCIAL LEARNING LICENSE 1.1
|
|
#
|
|
|
|
# 声明:本代码仅供学习和研究目的使用。使用者应遵守以下原则:
|
|
# 1. 不得用于任何商业用途。
|
|
# 2. 使用时应遵守目标平台的使用条款和robots.txt规则。
|
|
# 3. 不得进行大规模爬取或对平台造成运营干扰。
|
|
# 4. 应合理控制请求频率,避免给目标平台带来不必要的负担。
|
|
# 5. 不得用于任何非法或不当的用途。
|
|
#
|
|
# 详细许可条款请参阅项目根目录下的LICENSE文件。
|
|
# 使用本代码即表示您同意遵守上述原则和LICENSE中的所有条款。
|
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ZhihuContent(BaseModel):
|
|
"""
|
|
Zhihu content (answer, article, video)
|
|
"""
|
|
content_id: str = Field(default="", description="Content ID")
|
|
content_type: str = Field(default="", description="Content type (article | answer | zvideo)")
|
|
content_text: str = Field(default="", description="Content text, empty for video type")
|
|
content_url: str = Field(default="", description="Content landing page URL")
|
|
question_id: str = Field(default="", description="Question ID, has value when type is answer")
|
|
title: str = Field(default="", description="Content title")
|
|
desc: str = Field(default="", description="Content description")
|
|
created_time: int = Field(default=0, description="Create time")
|
|
updated_time: int = Field(default=0, description="Update time")
|
|
voteup_count: int = Field(default=0, description="Upvote count")
|
|
comment_count: int = Field(default=0, description="Comment count")
|
|
source_keyword: str = Field(default="", description="Source keyword")
|
|
creator_hash: str = Field(default="", description="Creator anonymized hash")
|
|
user_nickname: str = Field(default="", description="User nickname (masked)")
|
|
|
|
|
|
class ZhihuComment(BaseModel):
|
|
"""
|
|
Zhihu comment
|
|
"""
|
|
|
|
comment_id: str = Field(default="", description="Comment ID")
|
|
parent_comment_id: str = Field(default="", description="Parent comment ID")
|
|
content: str = Field(default="", description="Comment content")
|
|
publish_time: int = Field(default=0, description="Publish time")
|
|
sub_comment_count: int = Field(default=0, description="Sub-comment count")
|
|
like_count: int = Field(default=0, description="Like count")
|
|
dislike_count: int = Field(default=0, description="Dislike count")
|
|
content_id: str = Field(default="", description="Content ID")
|
|
content_type: str = Field(default="", description="Content type (article | answer | zvideo)")
|
|
creator_hash: str = Field(default="", description="Creator anonymized hash")
|
|
user_nickname: str = Field(default="", description="User nickname (masked)")
|
|
|
|
|
|
class ZhihuCreator(BaseModel):
|
|
"""
|
|
Zhihu creator (in-memory only; personal profile is no longer persisted)
|
|
"""
|
|
creator_hash: str = Field(default="", description="Creator anonymized hash")
|
|
user_nickname: str = Field(default="", description="User nickname (masked)")
|
|
follows: int = Field(default=0, description="Follows count")
|
|
fans: int = Field(default=0, description="Fans count")
|
|
anwser_count: int = Field(default=0, description="Answer count")
|
|
video_count: int = Field(default=0, description="Video count")
|
|
question_count: int = Field(default=0, description="Question count")
|
|
article_count: int = Field(default=0, description="Article count")
|
|
column_count: int = Field(default=0, description="Column count")
|
|
get_voteup_count: int = Field(default=0, description="Total upvotes received")
|