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

Implementation:666ghj BettaFish MediaCrawlerDB search

From Leeroopedia
Knowledge Sources
Domains Database, Information_Retrieval, domain:Social_Media_Analysis
Last Updated 2026-10-08 00:00 GMT

Overview

Concrete database search tool client providing five specialized query methods for mining social media sentiment data from a local MySQL/PostgreSQL database provided by the InsightEngine.

Description

The MediaCrawlerDB class encapsulates five AI Agent-callable search tools designed for a local database populated by the MindSpider crawler. Each tool targets a specific search intent: hot content discovery, global topic search, date-range topic search, comment extraction, and platform-specific search. The class uses a weighted hotness scoring algorithm (likes × 1.0 + comments × 5.0 + shares × 10.0 + views × 0.1) to rank results across 6+ social media platforms (Bilibili, Douyin, Weibo, Xiaohongshu, Kuaishou, Zhihu).

Usage

Import this class when you need to search a local social media database for public opinion content. It is used by the InsightEngine's `DeepSearchAgent.execute_search_tool` method.

Code Reference

Source Location

  • Repository: BettaFish
  • File: `InsightEngine/tools/search.py:L63-463`

Signature

class MediaCrawlerDB:
    W_LIKE = 1.0
    W_COMMENT = 5.0
    W_SHARE = 10.0
    W_VIEW = 0.1
    W_DANMAKU = 0.5

    def __init__(self):
        """Initialize the database search client."""

    def search_hot_content(
        self,
        time_period: Literal['24h', 'week', 'year'] = 'week',
        limit: int = 50
    ) -> DBResponse:
        """Find hottest content by weighted hotness score across all platforms."""

    def search_topic_globally(
        self,
        topic: str,
        limit_per_table: int = 100
    ) -> DBResponse:
        """Search all tables (content, comments, tags) for a topic."""

    def search_topic_by_date(
        self,
        topic: str,
        start_date: str,
        end_date: str,
        limit_per_table: int = 100
    ) -> DBResponse:
        """Search for a topic within a specific date range (YYYY-MM-DD)."""

    def get_comments_for_topic(
        self,
        topic: str,
        limit: int = 100
    ) -> DBResponse:
        """Extract public comments about a specific topic."""

    def search_topic_on_platform(
        self,
        platform: str,
        topic: str,
        start_date: str = None,
        end_date: str = None,
        limit: int = 100
    ) -> DBResponse:
        """Search for a topic on a specific platform (bilibili, douyin, weibo, xhs, kuaishou, zhihu, tieba)."""

Import

from InsightEngine.tools import MediaCrawlerDB, DBResponse

I/O Contract

Inputs

Name Type Required Description
topic str Yes (most tools) Search keyword/topic
time_period Literal['24h','week','year'] No Time range for hot content
start_date/end_date str For date tools Date range in YYYY-MM-DD format
platform str For platform tool Platform ID (bilibili, douyin, weibo, xhs, kuaishou, zhihu, tieba)
limit/limit_per_table int No Max results to return

Outputs

Name Type Description
DBResponse dataclass Contains tool_name, parameters, results (List[QueryResult]), results_count
QueryResult dataclass platform, content_type, title_or_content, author_nickname, url, publish_time, engagement, hotness_score

Usage Examples

Search Hot Content

from InsightEngine.tools import MediaCrawlerDB

db = MediaCrawlerDB()

# Get hottest content from the past week
response = db.search_hot_content(time_period='week', limit=50)
print(f"Found {response.results_count} hot items")
for r in response.results[:5]:
    print(f"  [{r.platform}] {r.title_or_content[:50]} (hotness: {r.hotness_score:.1f})")

Search Topic Globally

# Search across all platforms for a topic
response = db.search_topic_globally(topic="人工智能", limit_per_table=100)
print(f"Found {response.results_count} results across all platforms")

Search by Date Range

# Search within a specific date range
response = db.search_topic_by_date(
    topic="教育政策",
    start_date="2024-01-01",
    end_date="2024-06-30",
    limit_per_table=50
)

Related Pages

Implements Principle

Requires Environment

Page Connections

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