|
|
|
@ -67,7 +67,7 @@ async def is_article_exist(pool, article_url):
|
|
|
|
|
return False # 出错时默认返回False,避免影响正常流程
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def save_article_to_db(pool, article_title, account_name, article_url, publish_time, content, id):
|
|
|
|
|
async def save_article_to_db(pool, article_title, account_name, article_url, publish_time, content, source_id):
|
|
|
|
|
# 先检查文章是否已存在
|
|
|
|
|
if await is_article_exist(pool, article_url):
|
|
|
|
|
logger.info(f"文章已存在,跳过保存: {article_url}")
|
|
|
|
@ -80,7 +80,7 @@ async def save_article_to_db(pool, article_title, account_name, article_url, pub
|
|
|
|
|
(title, source, url, publish_time, content, source_id)
|
|
|
|
|
VALUES ($1, $2, $3, $4, $5, $6)
|
|
|
|
|
''', article_title, account_name, article_url,
|
|
|
|
|
publish_time, content, id)
|
|
|
|
|
publish_time, content, source_id)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logging.error(f"保存文章失败: {e}")
|
|
|
|
|
|
|
|
|
@ -198,7 +198,10 @@ if __name__ == '__main__':
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
logger.info(f"正在处理文章: {article_title} ({publish_time})")
|
|
|
|
|
|
|
|
|
|
logger.info(f"正在获取文章: {article_title}内容...")
|
|
|
|
|
content = get_article_content(article_url)
|
|
|
|
|
logger.info(f"成功获取文章: {article_title}内容。")
|
|
|
|
|
|
|
|
|
|
loop = asyncio.new_event_loop()
|
|
|
|
|
asyncio.set_event_loop(loop)
|
|
|
|
|