Selenium一直都是Python开源自动化浏览器工具的王者,但这两年微软开源的PlayWright异军突起,后来者居上,隐隐然有撼动Selenium江湖地位之势,本次我们来对比PlayWright与Selenium之间的差异,看看曾经的玫瑰花Selenium是否会变成蚊子血。
PlayWright的安装和使用PlayWright是由业界大佬微软(Microsoft)开源的端到端Web测试和自动化库,可谓是大厂背书,功能满格,虽然作为无头浏览器,该框架的主要作用是测试Web应用,但事实上,无头浏览器更多的是用于Web抓取目的,也就是爬虫。
首先终端运行安装命令:
pip3installplaywright
程序返回:
SuccessfullybuiltgreenletInstallingcollectedpackages:pyee,greenlet,playwrightAttemptinguninstall:greenletFoundexistinginstallation:greenlet2.0.2Uninstallinggreenlet-2.0.2:Successfullyuninstalledgreenlet-2.0.2Successfullyinstalledgreenlet-2.0.1playwright-1.30.0pyee-9.0.4
目前最新稳定版为1.30.0
随后可以选择直接安装浏览器驱动:
playwrightinstall
程序返回:
DownloadingChromium.0..38(playwrightbuildv)from