|
|
|
@ -112,10 +112,6 @@ class MetasoSpider(AbstractAiSeoSpider): |
|
|
|
def get_platform_name(self) -> str: |
|
|
|
return 'Metaso' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def __listen_response(self, response): |
|
|
|
url = response.url |
|
|
|
if response.status == 200: |
|
|
|
@ -194,6 +190,7 @@ class MetasoSpider(AbstractAiSeoSpider): |
|
|
|
|
|
|
|
else: |
|
|
|
pass |
|
|
|
|
|
|
|
def handle_listen_response_error(self, func): |
|
|
|
""" |
|
|
|
装饰器 用于处理请求回调中的异常 |
|
|
|
@ -214,6 +211,26 @@ class MetasoSpider(AbstractAiSeoSpider): |
|
|
|
|
|
|
|
return wrapper |
|
|
|
|
|
|
|
async def do_check_session(self) -> bool: |
|
|
|
try: |
|
|
|
await self.browser_page.goto(self.get_home_url(), timeout=200000) |
|
|
|
await asyncio.sleep(2) |
|
|
|
info = await self.browser_page.wait_for_selector( |
|
|
|
'#left-menu > div > div.LeftMenu_footer__qsJdJ > div > div > div > button', timeout=600000) |
|
|
|
await info.click() |
|
|
|
edu = self.browser_page.locator( |
|
|
|
'//div[@aria-label="每天有100搜索额度"]/following-sibling::div[1]//span[contains(@class, "MuiTypography-root")]') |
|
|
|
edu_txt = await edu.text_content() |
|
|
|
if edu_txt == '0': |
|
|
|
return False |
|
|
|
# 开始操作 |
|
|
|
chat_input_element = self.browser_page.locator("//textarea[contains(@class, 'search-consult-textarea')]") |
|
|
|
# 输入提问词 |
|
|
|
await chat_input_element.fill(self.prompt) |
|
|
|
logger.info(f"[{self.get_platform_name()}]查询还剩{edu_txt} 次") |
|
|
|
return True |
|
|
|
except Exception: |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
async def run(): |
|
|
|
|