v1.3.0: 每源独立采集周期 + 定制监控与新闻监控分离(独立配置/独立汇总) + 历史采样留档与提取API
This commit is contained in:
+28
-1
@@ -202,12 +202,14 @@ def _make_item(row):
|
||||
"summary": summary,
|
||||
"domain": domain,
|
||||
"entities": entities,
|
||||
"source_id": int(src_idx),
|
||||
"published_at": published.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
}
|
||||
|
||||
|
||||
def items_for_source(src_id, src_type=""):
|
||||
"""返回指定数据源的模拟条目(真实抓取失败/模拟源时回退用)"""
|
||||
"""返回指定数据源的模拟条目(真实抓取失败/模拟源时回退用)
|
||||
无内建匹配条目的源(如新建的定制监控源)→ 合成几条通用资讯,保证链路不空转。"""
|
||||
items = []
|
||||
for row in _NEWS:
|
||||
if row[3] == int(src_id):
|
||||
@@ -215,6 +217,31 @@ def items_for_source(src_id, src_type=""):
|
||||
if src_type:
|
||||
it["domain"] = src_type
|
||||
items.append(it)
|
||||
if not items:
|
||||
s = db.get_source(int(src_id)) if db else None
|
||||
name = (s.get("name") if s else "") or f"数据源{src_id}"
|
||||
generic = [
|
||||
("新品发布与里程碑", "该公司/该源今日宣布一项重要产品发布与里程碑进展,引发行业广泛关注,多位分析师上调预期。",
|
||||
"重大产品发布,行业里程碑。"),
|
||||
("重大战略合作", "该公司今日宣布与多家头部企业达成重大战略合作,涉及核心业务扩张与生态布局,市场反应积极。",
|
||||
"重大战略合作公告。"),
|
||||
("关键进展与新动态", "该领域出现关键性进展与新动态,相关技术/产品进入新阶段,预计将显著影响后续走向。",
|
||||
"关键进展,影响显著。"),
|
||||
("股价大幅波动", "受重大消息影响,该相关标的股价今日大幅波动,单日涨跌幅显著,市场情绪剧烈变化。",
|
||||
"股价大幅波动。"),
|
||||
("日常行业动态", "该领域今日整体平稳,行业例行消息与常规动态为主,无实质性重大变化。", "日常动态。"),
|
||||
]
|
||||
import hashlib
|
||||
from datetime import timedelta
|
||||
for i, (t, c, sm) in enumerate(generic):
|
||||
published = datetime.now() - timedelta(hours=2 + i)
|
||||
url = "https://news.example.com/s/" + hashlib.md5(f"{src_id}-{t}".encode()).hexdigest()[:16]
|
||||
items.append({
|
||||
"title": t, "url": url, "author": name,
|
||||
"content": c, "summary": sm, "domain": src_type or "综合",
|
||||
"entities": [], "source_id": int(src_id),
|
||||
"published_at": published.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
})
|
||||
return items
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user