52 lines
2 KiB
Python
52 lines
2 KiB
Python
from playwright.sync_api import sync_playwright
|
|
import json, time, re
|
|
|
|
def run():
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch_persistent_context(user_data_dir='/app/browser_context', headless=True)
|
|
page = browser.pages[0]
|
|
results = {}
|
|
|
|
# --- 1. ОБРАЩЕНИЯ ---
|
|
print('Разведка Обращений...')
|
|
page.goto('https://my.dom.gosuslugi.ru/citizen-cabinet/#!/appeals/applicant/search')
|
|
page.wait_for_load_state('networkidle')
|
|
time.sleep(7)
|
|
page.screenshot(path='/app/recon_appeals.png', full_page=True)
|
|
|
|
appeals = []
|
|
links = page.query_selector_all('a')
|
|
for link in links:
|
|
href = link.get_attribute('href') or ''
|
|
if 'appeals/view/' in href:
|
|
text = link.inner_text().strip()
|
|
if text:
|
|
appeals.append({'number': text, 'url': href})
|
|
results['appeals'] = appeals
|
|
print(f'Найдено обращений: {len(appeals)}')
|
|
|
|
# --- 2. ДОГОВОРЫ ---
|
|
print('Разведка Договоров...')
|
|
page.goto('https://my.dom.gosuslugi.ru/citizen-cabinet/#!/agreements/citizen/4b1aae97-01e6-4083-bf0c-029d01bbda2a?apartmentNumber=152')
|
|
page.wait_for_load_state('networkidle')
|
|
time.sleep(7)
|
|
page.screenshot(path='/app/recon_agreements.png', full_page=True)
|
|
|
|
agreements = []
|
|
links = page.query_selector_all('a')
|
|
for link in links:
|
|
href = link.get_attribute('href') or ''
|
|
if 'agreements/dogpoi/view/' in href:
|
|
text = link.inner_text().strip()
|
|
if text:
|
|
agreements.append({'name': text, 'url': href})
|
|
results['agreements'] = agreements
|
|
print(f'Найдено договоров: {len(agreements)}')
|
|
|
|
with open('/app/recon_data.json', 'w', encoding='utf-8') as f:
|
|
json.dump(results, f, ensure_ascii=False, indent=2)
|
|
|
|
browser.close()
|
|
|
|
if __name__ == '__main__':
|
|
run()
|