File size: 464 Bytes
0fce3a8
 
101de00
 
 
 
 
 
 
 
 
0fce3a8
101de00
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from playwright.sync_api import sync_playwright

def get_youtube_html(url="https://www.youtube.com"):
    """Fetches the HTML content of a YouTube page using Playwright."""
    with sync_playwright() as p:
        browser = p.chromium.launch()
        page = browser.new_page()
        page.goto(url)
        html = page.content()
        browser.close()
        return html

if __name__ == "__main__":
    html_content = get_youtube_html()
    print(html_content)