mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-07-27 23:10:27 +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)
73 lines
3.2 KiB
Python
73 lines
3.2 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_baidu_tieba.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 typing import Optional
|
||
|
||
from pydantic import BaseModel, Field
|
||
|
||
|
||
class TiebaNote(BaseModel):
|
||
"""
|
||
Baidu Tieba post
|
||
"""
|
||
note_id: str = Field(..., description="Post ID")
|
||
title: str = Field(..., description="Post title")
|
||
desc: str = Field(default="", description="Post description")
|
||
note_url: str = Field(..., description="Post link")
|
||
publish_time: str = Field(default="", description="Publish time")
|
||
creator_hash: str = Field(default="", description="创作者匿名哈希(不存原始用户链接)")
|
||
user_nickname: str = Field(default="", description="User nickname (已脱敏)")
|
||
tieba_name: str = Field(..., description="Tieba name")
|
||
tieba_link: str = Field(..., description="Tieba link")
|
||
total_replay_num: int = Field(default=0, description="Total reply count")
|
||
total_replay_page: int = Field(default=0, description="Total reply pages")
|
||
source_keyword: str = Field(default="", description="Source keyword")
|
||
|
||
|
||
class TiebaComment(BaseModel):
|
||
"""
|
||
Baidu Tieba comment
|
||
"""
|
||
|
||
comment_id: str = Field(..., description="Comment ID")
|
||
parent_comment_id: str = Field(default="", description="Parent comment ID")
|
||
content: str = Field(..., description="Comment content")
|
||
creator_hash: str = Field(default="", description="创作者匿名哈希(不存原始用户链接)")
|
||
user_nickname: str = Field(default="", description="User nickname (已脱敏)")
|
||
publish_time: str = Field(default="", description="Publish time")
|
||
sub_comment_count: int = Field(default=0, description="Sub-comment count")
|
||
note_id: str = Field(..., description="Post ID")
|
||
note_url: str = Field(..., description="Post link")
|
||
tieba_id: str = Field(..., description="Tieba ID")
|
||
tieba_name: str = Field(..., description="Tieba name")
|
||
tieba_link: str = Field(..., description="Tieba link")
|
||
|
||
|
||
class TiebaCreator(BaseModel):
|
||
"""
|
||
Baidu Tieba creator(教学版:个人资料不再落库,仅作内存对象)
|
||
"""
|
||
creator_hash: str = Field(default="", description="创作者匿名哈希(不存原始用户链接)")
|
||
user_nickname: str = Field(default="", description="User nickname (已脱敏)")
|
||
follows: int = Field(default=0, description="Follows count")
|
||
fans: int = Field(default=0, description="Fans count")
|
||
registration_duration: str = Field(default="", description="Registration duration")
|