Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:666ghj BettaFish MediaCrawler Submodule

From Leeroopedia
Knowledge Sources
Domains Crawling, Infrastructure
Last Updated 2026-10-08 21:30 GMT

Overview

Git submodule containing the MediaCrawler framework for multi-platform social media crawling (Xiaohongshu, Douyin, Kuaishou, Bilibili, Weibo, Tieba, Zhihu).

Description

This environment provides the MediaCrawler submodule, a third-party Python framework for crawling social media platforms. BettaFish integrates MediaCrawler as a git submodule under `MindSpider/DeepSentimentCrawling/MediaCrawler/`. The submodule handles browser-based crawling with Playwright, cookie-based authentication, and data storage to MySQL/PostgreSQL/SQLite/MongoDB. The PlatformCrawler component dynamically rewrites MediaCrawler's `db_config.py` to connect to the BettaFish database.

= Usage

Use this environment when running deep sentiment crawling tasks that require scraping social media platforms (Xiaohongshu, Douyin, Kuaishou, Bilibili, Weibo, Tieba, Zhihu). It is required by PlatformCrawler and MindSpider configuration validation.

System Requirements

Category Requirement Notes
OS Linux recommended macOS/Windows supported via Playwright
Hardware 4GB+ RAM Browser automation is memory-intensive
Disk 2GB+ For Playwright browsers and submodule code
Network Outbound HTTPS Required to reach social media platforms

Dependencies

System Packages

  • `git` (for submodule initialization)
  • Playwright browser binaries (`playwright install`)

Python Packages

  • `playwright` == 1.45.0
  • `Pillow` >= 10.0.0, < 11
  • `beautifulsoup4` >= 4.12.0
  • `lxml` >= 4.9.0
  • `parsel` == 1.9.1
  • `pyexecjs` == 1.5.1
  • `redis` >= 4.6.0
  • `tenacity` == 8.2.2

Credentials

No environment variables directly required by the submodule itself, but the following may be needed:

  • Platform login cookies (configured within MediaCrawler's own config)
  • `REDIS_DB_PWD`: Redis password (default: `123456`)
  • `REDIS_DB_PORT`: Redis port (default: `6379`)
  • `MONGODB_HOST`, `MONGODB_PORT`, `MONGODB_USER`, `MONGODB_PWD`, `MONGODB_DB_NAME`: If using MongoDB storage

Quick Install

# Initialize the git submodule
cd MindSpider/DeepSentimentCrawling
git submodule update --init --recursive

# Install Playwright browsers
playwright install

Code Evidence

Submodule initialization check from `MindSpider/DeepSentimentCrawling/platform_crawler.py:32-42`:

self.mediacrawler_path = Path(__file__).parent / "MediaCrawler"
self.supported_platforms = ['xhs', 'dy', 'ks', 'bili', 'wb', 'tieba', 'zhihu']

db_config_path = self.mediacrawler_path / "config" / "db_config.py"
if not self.mediacrawler_path.exists() or not db_config_path.exists():
    logger.error("MediaCrawler子模块未初始化或不完整")
    logger.error("请在项目根目录运行以下命令初始化子模块:")
    logger.error("   git submodule update --init --recursive")
    raise FileNotFoundError("MediaCrawler子模块未初始化,请先运行: git submodule update --init --recursive")

Dynamic database config rewrite from `MindSpider/DeepSentimentCrawling/platform_crawler.py:47-150`:

def configure_mediacrawler_db(self):
    db_dialect = (config.settings.DB_DIALECT or "mysql").lower()
    is_postgresql = db_dialect in ("postgresql", "postgres")
    db_config_path = self.mediacrawler_path / "config" / "db_config.py"
    with open(db_config_path, 'r', encoding='utf-8') as f:
        content = f.read()
    # Rewrites db_config.py with BettaFish's DB credentials
    new_config = f'''...
MYSQL_DB_PWD = "{config.settings.DB_PASSWORD}"
MYSQL_DB_USER = "{config.settings.DB_USER}"
...'''
    with open(db_config_path, 'w', encoding='utf-8') as f:
        f.write(new_config)

Common Errors

Error Message Cause Solution
`FileNotFoundError: MediaCrawler子模块未初始化` Git submodule not cloned Run `git submodule update --init --recursive`
`ImportError: 无法导入config.py配置文件` MindSpider config not found Ensure `MindSpider/config.py` exists and `.env` is configured
Playwright browser not found Browser binaries not installed Run `playwright install`

Compatibility Notes

  • Supported platforms: Xiaohongshu (`xhs`), Douyin (`dy`), Kuaishou (`ks`), Bilibili (`bili`), Weibo (`wb`), Tieba (`tieba`), Zhihu (`zhihu`).
  • Database rewriting: PlatformCrawler dynamically rewrites `MediaCrawler/config/db_config.py` at runtime — manual edits to that file are overwritten.
  • Redis: MediaCrawler uses Redis for cookie caching and task deduplication.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment