From 61031629931bd140a1eedc1e86d53799fa59b809 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 22 Apr 2022 20:18:54 +0200 Subject: [PATCH] No longer recommend Selenium --- .../scraping_with_selenium_on_docker.md | 42 ++----------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/programming/python/scraping_with_selenium_on_docker.md b/programming/python/scraping_with_selenium_on_docker.md index f5dd1cd..ec22ee5 100644 --- a/programming/python/scraping_with_selenium_on_docker.md +++ b/programming/python/scraping_with_selenium_on_docker.md @@ -1,39 +1,5 @@ -Check that Docker is installed and your user can run Docker: +Don't use Selenium, use [Playwright](https://playwright.dev/python/): -``` -$ docker run --rm hello-world -``` - -Docker should print a success message, if not, review your Docker installation. - -Create a virtualenv and install `testcontainers` with `selenium` support: - -``` -$ python3 -m venv selenium_testcontainers_venv -$ . selenium_testcontainers_venv/bin/activate -$ pip install -U pip -$ pip install testcontainers[selenium] -``` - -Use in a Python terminal: - -``` -$ python ->>> from testcontainers import selenium ->>> from selenium.webdriver import DesiredCapabilities ->>> chrome = selenium.BrowserWebDriverContainer(DesiredCapabilities.CHROME) ->>> chrome.start() ->>> webdriver = chrome.get_driver() ->>> ... -``` - -Use in code: - -``` -from testcontainers import selenium -from selenium.webdriver import DesiredCapabilities - -with selenium.BrowserWebDriverContainer(DesiredCapabilities.CHROME) as chrome: - webdriver = chrome.get_driver() - ... -``` +* Playwright automatically sets up headless browsers. +* Provides convenient abstractions for locating elements in a page (mostly no XPath required. It can match "intelligently" using text). +* Has a handy UI tool that records your actions in a browser and writes equivalent *readable* Playwright code. -- 2.47.3