Example repository for web scraping a single page application with Playwright.
I wrote this example application for Python 3.10, although it should work in python versions 3.9+. It should also work in lower versions of python 3 if the type hints are removed. To get started, you can pip install the necessary third-party requirements flask and playwright in a virtual environment and install Playwright's browser support.
pip install --upgrade pip
pip install flask playwright # or pip install -r requirements.txt
playwright installYou can run the script on the command line with the following:
python check_dancer_points.pyYou'll be asked to input a name or dancer ID.
You can run the flask application locally with the following:
flask --app check_dancer_points run --reloadThen go to localhost:5000. Provide a dancer's name or ID in the query string. For example, you could go to http://localhost:5000/?name_or_id=theodore%20williams to search for my name. %20 is the URL encoding for a space character.
Tests require the pytest and pytest-cov packages, so first, run:
pip install pytest pytest-cov # or pip install -r requirements.txtRun the pytests with:
pytest .Run the pytests with coverage:
pytest --cov --cov-report=html .