mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-05 23:32:49 +08:00
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
from app.database import SessionLocal
|
||
from app.crud.crud_source import create
|
||
from app.models.models import SourceType
|
||
from app.schemas.source_schema import InfoSourceCreate
|
||
|
||
# AI辅助生成:deepseek-v3-2,2026年3月20日
|
||
|
||
def init():
|
||
|
||
sources_data = [
|
||
{"name": "今日头条", "url": "toutiao"},
|
||
{"name": "百度热搜", "url": "baidu"},
|
||
{"name": "华尔街见闻", "url": "wallstreetcn-hot"},
|
||
{"name": "澎湃新闻", "url": "thepaper"},
|
||
{"name": "bilibili 热搜", "url": "bilibili-hot-search"},
|
||
{"name": "财联社热门", "url": "cls-hot"},
|
||
{"name": "凤凰网", "url": "ifeng"},
|
||
{"name": "贴吧", "url": "tieba"},
|
||
{"name": "微博", "url": "weibo"},
|
||
{"name": "抖音", "url": "douyin"},
|
||
{"name": "知乎", "url": "zhihu"}
|
||
]
|
||
|
||
for item in sources_data:
|
||
try:
|
||
with SessionLocal() as db:
|
||
|
||
create(db, InfoSourceCreate(
|
||
source_name=item["name"],
|
||
source_type=SourceType.HOT_TREND,
|
||
home_url=item["url"],
|
||
is_enabled=True
|
||
))
|
||
print(f"创建订阅源{item['name']}")
|
||
|
||
except Exception as e:
|
||
print(f"⚠️ 请求异常: {item['name']} - 错误: {e}")
|