|
|
@ -63,22 +63,25 @@ class YuanBaoSpider(AbstractAiSeoSpider): |
|
|
if self.fail_status: |
|
|
if self.fail_status: |
|
|
raise self.fail_exception |
|
|
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) |
|
|
answer_element = self.browser_page.locator("//div[@class='agent-chat__list__item__content']").nth(-1) |
|
|
box = await answer_element.bounding_box() |
|
|
box = await answer_element.bounding_box() |
|
|
logger.debug(f'answer_element: {box}') |
|
|
logger.debug(f'answer_element: {box}') |
|
|
view_port_height = box['height'] + 500 |
|
|
view_port_height = box['height'] + 500 |
|
|
# # 调整视口大小 |
|
|
|
|
|
|
|
|
# 调整视口大小 |
|
|
await self.browser_page.set_viewport_size({ |
|
|
await self.browser_page.set_viewport_size({ |
|
|
'width': 1920, |
|
|
'width': 1920, |
|
|
'height': int(view_port_height) |
|
|
'height': int(view_port_height) |
|
|
}) |
|
|
}) |
|
|
# 收起侧栏 |
|
|
# 收起侧栏 |
|
|
# await self.browser_page.locator("//div[@data-desc='fold']").click() |
|
|
# 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() |
|
|
screenshot_path = self._get_screenshot_path() |
|
|
await self.browser_page.screenshot(path=screenshot_path) |
|
|
await self.browser_page.screenshot(path=screenshot_path) |
|
|
|