main
HuangHai 1 week ago
parent 3fb6bd95b2
commit 3fec770149

@ -221,16 +221,26 @@ async def process_wechat_account(account_info, cookies, token):
async def main(): async def main():
"""主函数""" """主函数"""
cookies, token = await initialize_wechat_session() while True:
if not cookies or not token: try:
logger.error("初始化微信会话失败") logger.info("开始执行微信公众号文章采集任务")
return cookies, token = await initialize_wechat_session()
if not cookies or not token:
account_list = await get_wechat_sources() logger.error("初始化微信会话失败")
for account in account_list: continue
await process_wechat_account(account, cookies, token)
account_list = await get_wechat_sources()
driver.quit() 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__': if __name__ == '__main__':

Loading…
Cancel
Save