본문 바로가기
Python

playwright 실행해보기

by 앗사비 2022. 9. 19.
728x90

설치

pip install playwright
playwright install

playwright install 실패시 python -m playwright install 로 실행

 

실행

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch() #chromium, firefox, webkit 중에 하나 선택
    page = browser.new_page()
    page.goto("http://playwright.dev")
    print(page.title())
    browser.close()

 

출처 : https://playwright.dev/python/docs/library

 

---

 

Playwright 장점 : JS실행이 필요한 웹페이지가 많아져서, 브라우저 자동화 도구가 편하다고 함

https://news.hada.io/topic?id=7184 

 

---

 

레코딩 기능이 지원된다

https://playwright.dev/docs/codegen

playwright codegen wikipedia.org

 

---

 

프레임에서 html 추출

html = page.frame(name="fn").content()
728x90