-
Book Overview & Buying
-
Table Of Contents
Python Automation Cookbook - Third Edition
By :
Over time the complexity of web sites has grown tremendously, and there are many instances of web sites needing to render a complicated interface, perhaps created by iteration of multiple JS modules. Sometimes, nothing short of the real thing will work and trying to automate with a tool like requests feels deficient.
There have been projects to automate web browsers directly in the past, but Playwright is a new project aimed at that goal. It's conceived as a way of automatic testing, but it also can be used to automate interactions with a site.
Playwright can control most common browsers, including Safari, Chrome, Firefox, and Microsoft Edge. For our example, we will use Chrome.
Be sure to have Chrome installed – https://www.google.com/chrome/.
Add the playwright module to requirements.txt and install it:
$ echo " playwright==1.56.0" >> requirements.txt
$ uv pip install -r requirements.txt
To install playwright...