Should I scrape with Selenium or Playwright? (Python)¶
As a Python developer, choosing between Selenium and Playwright is... honestly not that big of a deal! Either one is perfectly fine, and if you end up not liking one of them it isn't too hard to switch to the other. So, which one should you use?
Installation: Playwright¶
Installing Playwright is much easier than installing Selenium.
The big difference between the two is something called the webdriver, the software that connects your code to the browser. Selenium requires you to download a webdriver for each browser you want to use, and then you have to make sure that the webdriver is the same version as the browser. Playwright, on the other hand, comes with its own webdriver so you don't have to worry about that.
You can use webdriver-manager to automatically download the correct webdriver for Selenium, but it's still a bit of extra work that isn't required when using Playwright.
There's now Selenium Manager which makes Selenium (potentially) as easy to install and use as Playwright, but I haven't tried it yet.
Documentation: Playwright¶
Playwright's documentation is much better than Selenium's.
Playwright's documentation is much more thorough and easier to understand than Selenium's. It's also much more up-to-date, and the documentation is written in a way that makes it easy to find what you're looking for. You can find Playwright's documentation here.
Selenium's documentation is located here, and is approximately ten thousand pages of nothing. It's not very well organized, and it's hard to find what you're looking for. I think they've been trying to make it better lately, but... they aren't quite there yet.
Ease of use: Selenium¶
Selenium is somewhat easier to use than Playwright.
Playwright was originally designed to be used with node.js (JavaScript), which works in a very different way than Python. As a result, Playwright's Python API is a bit more complicated than Selenium's. It's not that it's hard to use, it's just that it's less "Pythonic."
Selenium's API is much more straightforward, and it's easier to use (except when you have to wait for things to appear on the page, Playwright is far better at that).
Googling for answers: Maybe Selenium?¶
Selenium has a much larger community than Playwright.
When you're searching for answers to Selenium questions, you're much more likely to get the right answer nice and quick.
The one problem with searching for Selenium answers is that most of the folks who use it are writing automated tests in Java, which is not really the same thing as web scraping in Python. Usually you find a decent answer in Java, then run another search or two to figure out how to translate it to Python.