async def func(): start = time.time() while True: if time.time() - start > timeout: LOGGER.warning( f'Login failed: {account_id} <<<{page.page_source=}>>>') await notify('Login failed', f'{account_id}') return False # noinspection PyProtectedMember try: await page.goto( 'http://fresh.ahau.edu.cn/yxxt-v5/web/jkxxtb/tbJkxx.zf') except playwright._impl._api_types.Error as e: LOGGER.exception(e) continue await sleep(2) await page.evaluate(js_codes.login()) await sleep(2) await page.fill('#zh', account_id) await page.fill('#mm', password) await sleep(2) await page.click('#dlan') await sleep(2) if page.url != 'http://fresh.ahau.edu.cn/yxxt-v5/web/jkxxtb/tbJkxx.zf': await sleep(60 * 10) continue await sleep(5) return True
async def catch(e, local): LOGGER.exception(e) await notify('Error', f'```\n{e}\n```') return True, False
async def catch_func(e, local): if isinstance(e, CancelledError): return False, True LOGGER.exception(e) await notify('Error', f'```\n{e}\n```') return True, False