from playwright.sync_api import sync_playwright import time, os def run(): with sync_playwright() as p: try: browser = p.chromium.connect_over_cdp('http://127.0.0.1:9222') page = browser.contexts[0].pages[0] print(f'URL: {page.url}') # 1. Close popup if exists # We see a Restore popup in screenshots try: page.keyboard.press('Escape') except: pass # 2. Click the appeal print('Clicking 73-2026-5028...') page.get_by_text('73-2026-5028').first.click() time.sleep(10) print(f'New URL: {page.url}') # 3. Download download_btn = page.get_by_text('Скачать все') if download_btn.is_visible(): print('Found Download button. Clicking...') with page.expect_download(timeout=120000) as download_info: download_btn.click() download = download_info.value path = f'/app/downloads/test_appeal.zip' download.save_as(path) print(f'SUCCESS: Saved to {path}') else: print('Download button NOT found inside.') browser.close() except Exception as e: print(f'ERROR: {e}') if __name__ == '__main__': if not os.path.exists('/app/downloads'): os.makedirs('/app/downloads') run()