from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp('http://localhost:9222')
    page = browser.contexts[0].pages[0]
    
    # 1. Đi tới trang Profile chính
    url = 'https://www.facebook.com/profile.php?id=61594841053758'
    print('Navigating to root profile:', url)
    page.goto(url, wait_until='domcontentloaded', timeout=30000)
    page.wait_for_timeout(4000)
    page.screenshot(path=r'C:\Projects\Historical\FacebookAutoPoster\main_profile_page.png')
    print('Main profile screenshot saved!')
    browser.close()
