mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-06 00:57:51 +08:00
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
import json
|
|
|
|
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
|
|
|
|
|
|
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"}
|
|
]
|
|
|
|
# 遍历数据并发送 POST 请求
|
|
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}")
|