Showing
1 changed file
with
48 additions
and
9 deletions
| @@ -25,7 +25,7 @@ MindSpider 运行示例 | @@ -25,7 +25,7 @@ MindSpider 运行示例 | ||
| 25 | - **编程语言**: Python 3.9+ | 25 | - **编程语言**: Python 3.9+ |
| 26 | - **AI框架**: 默认Deepseek,可以接入多种api (话题提取与分析) | 26 | - **AI框架**: 默认Deepseek,可以接入多种api (话题提取与分析) |
| 27 | - **爬虫框架**: Playwright (浏览器自动化) | 27 | - **爬虫框架**: Playwright (浏览器自动化) |
| 28 | -- **数据库**: MySQL (数据持久化存储) | 28 | +- **数据库**: MySQL / PostgreSQL (数据持久化存储) |
| 29 | - **并发处理**: AsyncIO (异步并发爬取) | 29 | - **并发处理**: AsyncIO (异步并发爬取) |
| 30 | 30 | ||
| 31 | ## 项目结构 | 31 | ## 项目结构 |
| @@ -223,7 +223,7 @@ cd BettaFish/MindSpider | @@ -223,7 +223,7 @@ cd BettaFish/MindSpider | ||
| 223 | git submodule update --init --recursive | 223 | git submodule update --init --recursive |
| 224 | ``` | 224 | ``` |
| 225 | 225 | ||
| 226 | -> **注意**:MediaCrawler 的 Python 依赖会在首次运行 `python main.py` 时由系统自动检测并静默安装到当前环境。 | 226 | +> **注意**:MediaCrawler 的 Python 依赖会在首次运行 `uv run main.py --deep-sentiment` 时由系统自动检测并安装到当前环境。 |
| 227 | 227 | ||
| 228 | ### 2. 创建并激活环境 | 228 | ### 2. 创建并激活环境 |
| 229 | 229 | ||
| @@ -275,13 +275,18 @@ playwright install | @@ -275,13 +275,18 @@ playwright install | ||
| 275 | 复制.env.example文件为.env文件,放置在项目根目录。编辑 `.env` 文件,设置数据库和API配置: | 275 | 复制.env.example文件为.env文件,放置在项目根目录。编辑 `.env` 文件,设置数据库和API配置: |
| 276 | 276 | ||
| 277 | ```python | 277 | ```python |
| 278 | -# MySQL数据库配置 | 278 | +# 数据库配置(MySQL 示例) |
| 279 | +DB_DIALECT = "mysql" # mysql 或 postgresql | ||
| 279 | DB_HOST = "your_database_host" | 280 | DB_HOST = "your_database_host" |
| 280 | DB_PORT = 3306 | 281 | DB_PORT = 3306 |
| 281 | DB_USER = "your_username" | 282 | DB_USER = "your_username" |
| 282 | DB_PASSWORD = "your_password" | 283 | DB_PASSWORD = "your_password" |
| 283 | DB_NAME = "mindspider" | 284 | DB_NAME = "mindspider" |
| 284 | -DB_CHARSET = "utf8mb4" | 285 | +DB_CHARSET = "utf8mb4" # PostgreSQL 时可省略此项 |
| 286 | + | ||
| 287 | +# PostgreSQL 示例(将上方 DB_DIALECT 改为 postgresql,DB_PORT 改为 5432) | ||
| 288 | +# DB_DIALECT = "postgresql" | ||
| 289 | +# DB_PORT = 5432 | ||
| 285 | 290 | ||
| 286 | # MINDSPIDER API密钥 | 291 | # MINDSPIDER API密钥 |
| 287 | MINDSPIDER_BASE_URL=your_api_base_url | 292 | MINDSPIDER_BASE_URL=your_api_base_url |
| @@ -294,6 +299,8 @@ MINDSPIDER_MODEL_NAME=deepseek-chat | @@ -294,6 +299,8 @@ MINDSPIDER_MODEL_NAME=deepseek-chat | ||
| 294 | ```bash | 299 | ```bash |
| 295 | # 检查系统状态 | 300 | # 检查系统状态 |
| 296 | python main.py --status | 301 | python main.py --status |
| 302 | +# 或 | ||
| 303 | +uv run main.py --status | ||
| 297 | ``` | 304 | ``` |
| 298 | 305 | ||
| 299 | ## 使用指南 | 306 | ## 使用指南 |
| @@ -303,12 +310,18 @@ python main.py --status | @@ -303,12 +310,18 @@ python main.py --status | ||
| 303 | ```bash | 310 | ```bash |
| 304 | # 1. 运行话题提取(获取热点新闻和关键词) | 311 | # 1. 运行话题提取(获取热点新闻和关键词) |
| 305 | python main.py --broad-topic | 312 | python main.py --broad-topic |
| 313 | +# 或 | ||
| 314 | +uv run main.py --broad-topic | ||
| 306 | 315 | ||
| 307 | # 2. 运行爬虫(基于关键词爬取各平台内容) | 316 | # 2. 运行爬虫(基于关键词爬取各平台内容) |
| 308 | python main.py --deep-sentiment --test | 317 | python main.py --deep-sentiment --test |
| 318 | +# 或 | ||
| 319 | +uv run main.py --deep-sentiment --test | ||
| 309 | 320 | ||
| 310 | # 或者一次性运行完整流程 | 321 | # 或者一次性运行完整流程 |
| 311 | python main.py --complete --test | 322 | python main.py --complete --test |
| 323 | +# 或 | ||
| 324 | +uv run main.py --complete --test | ||
| 312 | ``` | 325 | ``` |
| 313 | 326 | ||
| 314 | ### 单独使用模块 | 327 | ### 单独使用模块 |
| @@ -316,12 +329,18 @@ python main.py --complete --test | @@ -316,12 +329,18 @@ python main.py --complete --test | ||
| 316 | ```bash | 329 | ```bash |
| 317 | # 只获取今日热点和关键词 | 330 | # 只获取今日热点和关键词 |
| 318 | python main.py --broad-topic | 331 | python main.py --broad-topic |
| 332 | +# 或 | ||
| 333 | +uv run main.py --broad-topic | ||
| 319 | 334 | ||
| 320 | # 只爬取特定平台 | 335 | # 只爬取特定平台 |
| 321 | python main.py --deep-sentiment --platforms xhs dy --test | 336 | python main.py --deep-sentiment --platforms xhs dy --test |
| 337 | +# 或 | ||
| 338 | +uv run main.py --deep-sentiment --platforms xhs dy --test | ||
| 322 | 339 | ||
| 323 | # 指定日期 | 340 | # 指定日期 |
| 324 | python main.py --broad-topic --date 2024-01-15 | 341 | python main.py --broad-topic --date 2024-01-15 |
| 342 | +# 或 | ||
| 343 | +uv run main.py --broad-topic --date 2024-01-15 | ||
| 325 | ``` | 344 | ``` |
| 326 | 345 | ||
| 327 | ## 爬虫配置(重要) | 346 | ## 爬虫配置(重要) |
| @@ -334,6 +353,8 @@ python main.py --broad-topic --date 2024-01-15 | @@ -334,6 +353,8 @@ python main.py --broad-topic --date 2024-01-15 | ||
| 334 | ```bash | 353 | ```bash |
| 335 | # 测试小红书爬取(会弹出二维码) | 354 | # 测试小红书爬取(会弹出二维码) |
| 336 | python main.py --deep-sentiment --platforms xhs --test | 355 | python main.py --deep-sentiment --platforms xhs --test |
| 356 | +# 或 | ||
| 357 | +uv run main.py --deep-sentiment --platforms xhs --test | ||
| 337 | # 用小红书APP扫码登录,登录成功后会自动保存状态 | 358 | # 用小红书APP扫码登录,登录成功后会自动保存状态 |
| 338 | ``` | 359 | ``` |
| 339 | 360 | ||
| @@ -341,25 +362,27 @@ python main.py --deep-sentiment --platforms xhs --test | @@ -341,25 +362,27 @@ python main.py --deep-sentiment --platforms xhs --test | ||
| 341 | ```bash | 362 | ```bash |
| 342 | # 测试抖音爬取 | 363 | # 测试抖音爬取 |
| 343 | python main.py --deep-sentiment --platforms dy --test | 364 | python main.py --deep-sentiment --platforms dy --test |
| 365 | +# 或 | ||
| 366 | +uv run main.py --deep-sentiment --platforms dy --test | ||
| 344 | # 用抖音APP扫码登录 | 367 | # 用抖音APP扫码登录 |
| 345 | ``` | 368 | ``` |
| 346 | 369 | ||
| 347 | 3. **其他平台同理** | 370 | 3. **其他平台同理** |
| 348 | ```bash | 371 | ```bash |
| 349 | # 快手 | 372 | # 快手 |
| 350 | -python main.py --deep-sentiment --platforms ks --test | 373 | +uv run main.py --deep-sentiment --platforms ks --test |
| 351 | 374 | ||
| 352 | # B站 | 375 | # B站 |
| 353 | -python main.py --deep-sentiment --platforms bili --test | 376 | +uv run main.py --deep-sentiment --platforms bili --test |
| 354 | 377 | ||
| 355 | # 微博 | 378 | # 微博 |
| 356 | -python main.py --deep-sentiment --platforms wb --test | 379 | +uv run main.py --deep-sentiment --platforms wb --test |
| 357 | 380 | ||
| 358 | # 贴吧 | 381 | # 贴吧 |
| 359 | -python main.py --deep-sentiment --platforms tieba --test | 382 | +uv run main.py --deep-sentiment --platforms tieba --test |
| 360 | 383 | ||
| 361 | # 知乎 | 384 | # 知乎 |
| 362 | -python main.py --deep-sentiment --platforms zhihu --test | 385 | +uv run main.py --deep-sentiment --platforms zhihu --test |
| 363 | ``` | 386 | ``` |
| 364 | 387 | ||
| 365 | ### 登录问题排除 | 388 | ### 登录问题排除 |
| @@ -385,9 +408,13 @@ https://github.com/666ghj/BettaFish/issues/185 | @@ -385,9 +408,13 @@ https://github.com/666ghj/BettaFish/issues/185 | ||
| 385 | ```bash | 408 | ```bash |
| 386 | # 小规模测试(推荐先这样测试) | 409 | # 小规模测试(推荐先这样测试) |
| 387 | python main.py --complete --test | 410 | python main.py --complete --test |
| 411 | +# 或 | ||
| 412 | +uv run main.py --complete --test | ||
| 388 | 413 | ||
| 389 | # 调整爬取数量 | 414 | # 调整爬取数量 |
| 390 | python main.py --complete --max-keywords 20 --max-notes 30 | 415 | python main.py --complete --max-keywords 20 --max-notes 30 |
| 416 | +# 或 | ||
| 417 | +uv run main.py --complete --max-keywords 20 --max-notes 30 | ||
| 391 | ``` | 418 | ``` |
| 392 | 419 | ||
| 393 | ### 高级功能 | 420 | ### 高级功能 |
| @@ -396,18 +423,26 @@ python main.py --complete --max-keywords 20 --max-notes 30 | @@ -396,18 +423,26 @@ python main.py --complete --max-keywords 20 --max-notes 30 | ||
| 396 | ```bash | 423 | ```bash |
| 397 | # 提取指定日期的话题 | 424 | # 提取指定日期的话题 |
| 398 | python main.py --broad-topic --date 2024-01-15 | 425 | python main.py --broad-topic --date 2024-01-15 |
| 426 | +# 或 | ||
| 427 | +uv run main.py --broad-topic --date 2024-01-15 | ||
| 399 | 428 | ||
| 400 | # 爬取指定日期的内容 | 429 | # 爬取指定日期的内容 |
| 401 | python main.py --deep-sentiment --date 2024-01-15 | 430 | python main.py --deep-sentiment --date 2024-01-15 |
| 431 | +# 或 | ||
| 432 | +uv run main.py --deep-sentiment --date 2024-01-15 | ||
| 402 | ``` | 433 | ``` |
| 403 | 434 | ||
| 404 | #### 2. 指定平台爬取 | 435 | #### 2. 指定平台爬取 |
| 405 | ```bash | 436 | ```bash |
| 406 | # 只爬取B站和抖音 | 437 | # 只爬取B站和抖音 |
| 407 | python main.py --deep-sentiment --platforms bili dy --test | 438 | python main.py --deep-sentiment --platforms bili dy --test |
| 439 | +# 或 | ||
| 440 | +uv run main.py --deep-sentiment --platforms bili dy --test | ||
| 408 | 441 | ||
| 409 | # 爬取所有平台的特定数量内容 | 442 | # 爬取所有平台的特定数量内容 |
| 410 | python main.py --deep-sentiment --max-keywords 30 --max-notes 20 | 443 | python main.py --deep-sentiment --max-keywords 30 --max-notes 20 |
| 444 | +# 或 | ||
| 445 | +uv run main.py --deep-sentiment --max-keywords 30 --max-notes 20 | ||
| 411 | ``` | 446 | ``` |
| 412 | 447 | ||
| 413 | ## 常用参数 | 448 | ## 常用参数 |
| @@ -443,12 +478,16 @@ HEADLESS = False | @@ -443,12 +478,16 @@ HEADLESS = False | ||
| 443 | 478 | ||
| 444 | # 重新运行登录 | 479 | # 重新运行登录 |
| 445 | python main.py --deep-sentiment --platforms xhs --test | 480 | python main.py --deep-sentiment --platforms xhs --test |
| 481 | +# 或 | ||
| 482 | +uv run main.py --deep-sentiment --platforms xhs --test | ||
| 446 | ``` | 483 | ``` |
| 447 | 484 | ||
| 448 | ### 2. 数据库连接失败 | 485 | ### 2. 数据库连接失败 |
| 449 | ```bash | 486 | ```bash |
| 450 | # 检查配置 | 487 | # 检查配置 |
| 451 | python main.py --status | 488 | python main.py --status |
| 489 | +# 或 | ||
| 490 | +uv run main.py --status | ||
| 452 | 491 | ||
| 453 | # 检查config.py中的数据库配置是否正确 | 492 | # 检查config.py中的数据库配置是否正确 |
| 454 | ``` | 493 | ``` |
-
Please register or login to post a comment