Browse Source

适配nano

master
zhurunlin 4 months ago
parent
commit
6e7062e097
  1. 12
      spiders/ai_seo/nanometer.py

12
spiders/ai_seo/nanometer.py

@ -32,10 +32,10 @@ class NanometerSpider(AbstractAiSeoSpider):
# 开始操作
await self.browser_page.goto(self.get_home_url(), timeout=600000)
#开启深度思考
await self.browser_page.locator('//*[@id="nworld-app-container"]/div/div[1]/div[1]/div/div/div/div/div[2]/div[1]/div[1]/div[2]/div[1]/section/div').click()
chat_input_element = self.browser_page.locator("//textarea[@id='composition-input']")
# await self.browser_page.locator('//*[@id="NMAI_SIDEBAR_MENU"]/div/div[2]').click()
chat_input_element = self.browser_page.locator('//*[@id="NM-ASSISTANT_chat_input"]')
# 输入提问词
await chat_input_element.fill(self.prompt)
await chat_input_element.press_sequentially(self.prompt)
await self.browser_page.keyboard.press('Enter')
# 监听请求
self.browser_page.on('response', partial(self.__listen_response))
@ -47,10 +47,10 @@ class NanometerSpider(AbstractAiSeoSpider):
raise self.fail_exception
# 获取回答元素
answer_element = self.browser_page.locator("//div[@class='js-article-content']").nth(-1)
box = await answer_element.bounding_box()
# answer_element = self.browser_page.locator("//div[@id='search-list']")
box = await self.browser_page.evaluate("() => document.body.scrollHeight")
logger.debug(f'answer_element: {box}')
view_port_height = box['height'] + 500
view_port_height = box+ 500
# 调整视口大小
await self.browser_page.set_viewport_size({
'width': 1920,

Loading…
Cancel
Save