From 10922ec1d284494415ccec9f1d415b821ec8239e Mon Sep 17 00:00:00 2001 From: zzx Date: Wed, 9 Jul 2025 15:35:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=83=E5=AE=9D=E5=92=8C?= =?UTF-8?q?=E6=96=87=E5=BF=83=E4=B8=80=E8=A8=80=E5=B9=B3=E5=8F=B0=E6=88=AA?= =?UTF-8?q?=E5=9B=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spiders/ai_seo/yiyan.py | 12 ++++++++---- spiders/ai_seo/yuanbao.py | 15 +++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/spiders/ai_seo/yiyan.py b/spiders/ai_seo/yiyan.py index a34171c..b69c227 100644 --- a/spiders/ai_seo/yiyan.py +++ b/spiders/ai_seo/yiyan.py @@ -63,20 +63,24 @@ class YiYanSpider(AbstractAiSeoSpider): if self.fail_status: raise self.fail_exception + # 打开搜索结果 + open_search_btn_element = self.browser_page.locator("div:text('条网页信息源')") + if await open_search_btn_element.count() > 0: + await open_search_btn_element.click() + # 获取回答元素 answer_element = self.browser_page.locator("//div[contains(@class, 'dialog-card-wrapper')]").nth(-1) box = await answer_element.bounding_box() logger.debug(f'answer_element: {box}') view_port_height = box['height'] + 1000 + # 调整视口大小 await self.browser_page.set_viewport_size({ 'width': 1920, 'height': int(view_port_height) }) - # 打开搜索结果 - open_search_btn_element = self.browser_page.locator("div:text('条网页信息源')") - if await open_search_btn_element.count() > 0: - await open_search_btn_element.click() + + await asyncio.sleep(2) # 截图 screenshot_path = self._get_screenshot_path() await self.browser_page.screenshot(path=screenshot_path) diff --git a/spiders/ai_seo/yuanbao.py b/spiders/ai_seo/yuanbao.py index 9fd146a..75d23f6 100644 --- a/spiders/ai_seo/yuanbao.py +++ b/spiders/ai_seo/yuanbao.py @@ -63,22 +63,25 @@ class YuanBaoSpider(AbstractAiSeoSpider): if self.fail_status: raise self.fail_exception - # # 获取回答元素 + # 打开联网搜索结果 + search_list_element = self.browser_page.locator("(//div[contains(@data-title, '资料作为参考')])[1]/span") + if await search_list_element.is_visible(): + await search_list_element.click() + + # 获取回答元素 answer_element = self.browser_page.locator("//div[@class='agent-chat__list__item__content']").nth(-1) box = await answer_element.bounding_box() logger.debug(f'answer_element: {box}') view_port_height = box['height'] + 500 - # # 调整视口大小 + # 调整视口大小 await self.browser_page.set_viewport_size({ 'width': 1920, 'height': int(view_port_height) }) # 收起侧栏 # await self.browser_page.locator("//div[@data-desc='fold']").click() - # 打开联网搜索结果 - search_list_element = self.browser_page.locator("(//div[contains(@data-title, '资料作为参考')])[1]/span") - if await search_list_element.is_visible(): - await search_list_element.click() + await asyncio.sleep(2) + # 截图 screenshot_path = self._get_screenshot_path() await self.browser_page.screenshot(path=screenshot_path)