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]
    
    url = 'https://www.facebook.com/profile.php?id=61594841053758&sk=about_work_and_education'
    print('Navigating to:', url)
    page.goto(url, wait_until='domcontentloaded', timeout=30000)
    page.wait_for_timeout(4000)
    
    # In ra tất cả text trên phần nội dung
    text = page.locator("div[role='main']").inner_text()
    print('MAIN CONTENT:\n', text)
    
    page.screenshot(path=r'C:\Projects\Historical\FacebookAutoPoster\work_edu.png')
    browser.close()
