playwright自动测试库的爬虫使用

在尝试使用playwright之前,也使用过Selenium,Selenium依赖多种不同的driver,根据浏览器的不断更新,就要不断去维护这些driver,以及处理相应的适用性问题,对于整体的产品来看,显得太重,playwright的这方面封装会更加轻量级,所以尝试了把playwright的使用

使用之前,首先在已新建的虚拟环境下,可以:

pip install playwright
//2.安装相应的封装好的驱动
playwight install

第二步可能网络不好时会下载失败,多尝试,下载后安装在用户的一个隐藏目录下(具体位置忘了)

下面我们对一个网站进行爬虫,并且模拟登录。

from playwright.sync_api import sync_playwright


def main():
    with sync_playwright() as p:
        browser = p.firefox.launch(headless=False)
        context = browser.

你可能感兴趣的:(爬虫,python,firefox)