main
HuangHai 7 days ago
parent 3fb6bd95b2
commit 3fec770149

@ -221,16 +221,26 @@ async def process_wechat_account(account_info, cookies, token):
async def main():
"""主函数"""
cookies, token = await initialize_wechat_session()
if not cookies or not token:
logger.error("初始化微信会话失败")
return
account_list = await get_wechat_sources()
for account in account_list:
await process_wechat_account(account, cookies, token)
driver.quit()
while True:
try:
logger.info("开始执行微信公众号文章采集任务")
cookies, token = await initialize_wechat_session()
if not cookies or not token:
logger.error("初始化微信会话失败")
continue
account_list = await get_wechat_sources()
for account in account_list:
await process_wechat_account(account, cookies, token)
logger.info("本次采集任务完成等待30分钟后再次执行")
await asyncio.sleep(30 * 60) # 30分钟
except Exception as e:
logger.error(f"主循环发生错误: {e}")
await asyncio.sleep(30 * 60) # 出错后也等待30分钟
finally:
if 'driver' in globals():
driver.quit()
if __name__ == '__main__':

Loading…
Cancel
Save