From e7c780c32230814d770c96c3e8e0a622ad2828de Mon Sep 17 00:00:00 2001 From: zzx Date: Fri, 1 Aug 2025 16:36:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=96=87=E5=BF=83?= =?UTF-8?q?=E4=B8=80=E8=A8=80=20session=E6=A3=80=E6=9F=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spiders/ai_seo/yiyan.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spiders/ai_seo/yiyan.py b/spiders/ai_seo/yiyan.py index f58e86b..1d3efb7 100644 --- a/spiders/ai_seo/yiyan.py +++ b/spiders/ai_seo/yiyan.py @@ -168,7 +168,6 @@ class YiYanSpider(AbstractAiSeoSpider): )) self.ai_answer.search_result = ai_search_result_list - async def check_login(self): # 找登录后才会出现的侧边栏 try: @@ -182,6 +181,22 @@ class YiYanSpider(AbstractAiSeoSpider): await AiSeoApis.update_spider_session(self.session_info['id'], 2) raise Exception(f"{self.get_platform_name()}登录失败 session_id: {self.session_info['id']}") + async def do_check_session(self) -> bool: + try: + await self.browser_page.goto(self.get_home_url(), timeout=200000) + await asyncio.sleep(2) + # 检查登录状态 + await self.check_login() + # 开始操作 + chat_input_element = self.browser_page.locator("//div[@class='yc-editor']") + await chat_input_element.click() + await asyncio.sleep(2) + # 输入提问词 + await self.browser_page.keyboard.insert_text(self.prompt) + return True + except Exception: + return False + def get_platform_id(self) -> int: return 6