fix: Update sudrf routing to /appeals/ and exclude general navigation URLs from details crawler

This commit is contained in:
Admin 2026-07-03 11:33:32 +04:00
parent 378ec2ebca
commit c1ad8b3d4c

View file

@ -82,7 +82,7 @@ async def run_mission():
logger.info("Login detected. Navigating to appeals history...") logger.info("Login detected. Navigating to appeals history...")
send_tg("✅ **Авторизация успешна!** Начинаю сбор обращений...") send_tg("✅ **Авторизация успешна!** Начинаю сбор обращений...")
await page.goto("https://ej.sudrf.ru/#/appeals") await page.goto("https://ej.sudrf.ru/appeals/")
await asyncio.sleep(10) # wait for page to render appeals list await asyncio.sleep(10) # wait for page to render appeals list
# Take list page screenshot # Take list page screenshot
@ -103,7 +103,9 @@ async def run_mission():
href = await link.get_attribute("href") href = await link.get_attribute("href")
text = await link.inner_text() text = await link.inner_text()
if href and ("appeal" in href or "card" in href or "request" in href): if href and ("appeal" in href or "card" in href or "request" in href):
links.append({"href": href, "text": text.strip()}) # Исключаем общие страницы
if href.strip() not in ("/appeal/", "/appeals/", "/appeal", "/appeals", "#/appeal/", "#/appeals/"):
links.append({"href": href, "text": text.strip()})
logger.info(f"Found {len(links)} matching links on page: {links}") logger.info(f"Found {len(links)} matching links on page: {links}")
@ -150,15 +152,17 @@ async def run_mission():
for appeal in parsed_appeals: for appeal in parsed_appeals:
href = appeal.get("href") href = appeal.get("href")
if href and href not in processed_hrefs: if href and href not in processed_hrefs:
detail_hrefs.append(href) if href.strip() not in ("/appeal/", "/appeals/", "/appeal", "/appeals", "#/appeal/", "#/appeals/"):
processed_hrefs.add(href) detail_hrefs.append(href)
processed_hrefs.add(href)
# Also check all links for hrefs like #/appeals/view/ or similar # Also check all links for hrefs like #/appeals/view/ or similar
for link in links: for link in links:
href = link["href"] href = link["href"]
if href and href not in processed_hrefs: if href and href not in processed_hrefs:
detail_hrefs.append(href) if href.strip() not in ("/appeal/", "/appeals/", "/appeal", "/appeals", "#/appeal/", "#/appeals/"):
processed_hrefs.add(href) detail_hrefs.append(href)
processed_hrefs.add(href)
logger.info(f"Unique detail pages to process: {detail_hrefs}") logger.info(f"Unique detail pages to process: {detail_hrefs}")