- docs: 删除 CLAUDE.md / continuation.md / english-news-plan.md 及旧版 intlnews_usage.*,
统一迁移到 docs/{README,architecture,quickstart,usage,pipeline,configuration,deployment,development,faq}.md
- README: 精简为仓库入口,指向 docs/
- configs/sources.yaml: 更新注释指向新文档
- .env.example: 修正 DashScope Embedding 端点说明
Pipeline 修复:
- dedup/llm/embedding/vectorstore/reporter: 过滤 M2 no_content / 空正文,避免污染下游与 Qdrant
- dedup/pipeline: 改为先写唯一文件再写指纹,避免崩溃导致文章永久丢失
- crawler/orchestrator: sources_crawled 改为“尝试数”,成功数 = crawled - failed
- crawler/storage: write_index_jsonl 从文章路径推断日期,修复跨天/测试路径问题
- scheduler/pipeline: STEP_TIMEOUTS 实际生效(SIGALRM)
- scheduler/reporter: emb_count 排除 index.json;日报跳过无原文事件
- vectorstore/pipeline: payload 增加 source_ids;--recreate --all 时空日期也重建 collection
- app/cli: extract/dedup/translate/embed/index/pipeline 支持 --date;embed/index 支持 --all;crawl 全源失败返回非零
- scripts: domestic_full/crawl_8g/crawl_2g/pipeline 安全加载 .env;M1 全失败不标记且最终退出码=1
81 lines
2.5 KiB
Bash
Executable File
81 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
||
# =============================================
|
||
# 国内服务器:8G headful + HTTP 代理抓取
|
||
# =============================================
|
||
# 适用场景:
|
||
# - 所有新闻源直接使用 headful Playwright 浏览器抓取
|
||
# - HTTP 代理 (127.0.0.1:3128) → Privoxy → SOCKS5(ss-local) 访问海外
|
||
# - 比海外 RSS 方式抓取更可靠,解决反爬问题
|
||
#
|
||
# 前置条件:
|
||
# sudo apt install xvfb
|
||
# Xvfb :99 -screen 0 1280x1024x24 & # 首次启动
|
||
# HTTP 代理 127.0.0.1:3128 已运行(privoxy)
|
||
#
|
||
# 用法:
|
||
# bash scripts/domestic_crawl_8g.sh # 抓取全部源
|
||
# bash scripts/domestic_crawl_8g.sh reuters # 只抓取指定源
|
||
# =============================================
|
||
set -euo pipefail
|
||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||
cd "$PROJECT_DIR"
|
||
|
||
LOG() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"; }
|
||
|
||
LOG "══════ 国内 8G headful + HTTP 代理抓取 ══════"
|
||
LOG "Profile: 8g_headful"
|
||
LOG "内存上限: 7500 MB"
|
||
LOG "浏览器模式: headful (Xvfb :99)"
|
||
LOG "HTTP 代理: 127.0.0.1:3128 (Privoxy → SOCKS5)"
|
||
|
||
# ── 加载 .env ──
|
||
export HTTP_PROXY=http://127.0.0.1:3128
|
||
export HTTPS_PROXY=http://127.0.0.1:3128
|
||
if [ -f .env ]; then
|
||
set -a
|
||
. ./.env
|
||
set +a
|
||
fi
|
||
|
||
# ── 启动 Xvfb(如果尚未运行)──
|
||
if ! pgrep -x "Xvfb" > /dev/null; then
|
||
LOG "启动 Xvfb 虚拟显示器 :99 ..."
|
||
Xvfb :99 -screen 0 1280x1024x24 -ac +extension RANDR &
|
||
sleep 1
|
||
LOG "Xvfb 已启动 (PID: $(pgrep -x Xvfb))"
|
||
else
|
||
LOG "Xvfb 已在运行 (PID: $(pgrep -x Xvfb))"
|
||
fi
|
||
|
||
export DISPLAY=:99
|
||
|
||
# ── 设置 Profile ──
|
||
export EN_NEWS_PROFILE="8g_headful"
|
||
|
||
# ── 执行抓取 ──
|
||
SOURCE_ARG=""
|
||
if [ $# -ge 1 ]; then
|
||
SOURCE_ARG="--source $1"
|
||
LOG "目标源: $1"
|
||
else
|
||
LOG "目标源: 全部启用源"
|
||
fi
|
||
|
||
if PYTHONPATH=. .venv/bin/python3 -c "
|
||
from crawler.orchestrator import run_crawl_sync
|
||
import sys
|
||
source_filter = sys.argv[1] if len(sys.argv) > 1 else None
|
||
stats = run_crawl_sync(source_filter=source_filter)
|
||
print(f'抓取完成: {stats.sources_crawled} 源, {stats.total_articles} 篇')
|
||
if stats.sources_crawled > 0 and stats.sources_failed >= stats.sources_crawled:
|
||
print(f'❌ 所有源抓取失败(sources_failed={stats.sources_failed})', file=sys.stderr)
|
||
sys.exit(1)
|
||
" "${1:-}"; then
|
||
LOG "══════ 8G 抓取完成 ✅ ══════"
|
||
else
|
||
LOG "❌ 8G 抓取失败:本次未标记完成"
|
||
exit 1
|
||
fi
|