From 536d059bafa09eb96db7e6222e95e7434c7a5ad0 Mon Sep 17 00:00:00 2001 From: "pierre.geeraert" Date: Mon, 3 Aug 2026 12:03:08 +0100 Subject: [PATCH 1/2] first files --- united-utilities-scarper.py | 72 +++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 united-utilities-scarper.py diff --git a/united-utilities-scarper.py b/united-utilities-scarper.py new file mode 100644 index 0000000..416ee90 --- /dev/null +++ b/united-utilities-scarper.py @@ -0,0 +1,72 @@ +import asyncio +from playwright.async_api import async_playwright + +UU_EMAIL = "email@gmail.com" +UU_PASSWORD = "password" + +async def download_uu_bill_live(): + async with async_playwright() as p: + # Opens visible browser with 1.5 second step delay + browser = await p.chromium.launch(headless=False, slow_mo=1500) + page = await browser.new_page() + + print("Opening United Utilities homepage...") + await page.goto("https://unitedutilities.com") + + # Handle cookie banner (confirmed working) + try: + await page.click("button:has-text('Accept All')", timeout=5000) + print("Cookies accepted.") + except Exception: + pass + + # NEW STEP: Click the header login button based on your HTML code + print("Clicking 'LOG IN / REGISTER' button in the header...") + await page.click("a.c-navigation__actions-btn:has-text('LOG IN / REGISTER')") + + # Wait for the login portal page to fully transition and load + print("Waiting for login portal page to load...") + await page.wait_for_url("https://myaccount.unitedutilities.com/**", timeout=15000) + + print("Typing credentials live...") + # Targets the unique ID 'login-email' from your HTML snippet + await page.fill("#login-email", UU_EMAIL) + + # Targets the likely matching password ID structure + await page.fill("#PasswordMasking", UU_PASSWORD) + + + print("Clicking submit login form...") + await page.click("#login-btn") + + + print("Waiting for dashboard to load...") + await page.wait_for_url("https://myaccount.unitedutilities.com/Secure/Dashboard", timeout=30000) + + + print("Navigating to billing section...") + await page.click("text=View bills and payments") + + print("Clicking 'View statement' button...") + await page.click("a[href*='type=viewStatement']") + + # NEW STEP: Wait for the dynamic bills table to finish loading + print("Waiting for bills table to load...") + await page.wait_for_selector("table#viewBill tbody tr") + + # Trigger and catch the file download pipeline + async with page.expect_download() as download_info: + print("Clicking the newest bill download link in the table...") + # Targets the very first row's download link inside the table body + await page.locator("table#viewBill tbody tr").first.locator("a[href*='DownloadBill.aspx']").click() + + download = await download_info.value + save_path = "./united_utilities_bill.pdf" + await download.save_as(save_path) + print(f"Success! Newest bill saved to {save_path}") + + print("Finishing up, closing browser in 5 seconds...") + await asyncio.sleep(5) + await browser.close() + +asyncio.run(download_uu_bill_live()) From f59c81517c5c85e6d00f5030cbed226f781f3bbe Mon Sep 17 00:00:00 2001 From: "pierre.geeraert" Date: Mon, 3 Aug 2026 12:08:05 +0100 Subject: [PATCH 2/2] adding good files --- .gitignore | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 + 2 files changed, 172 insertions(+) create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0dbf2f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,170 @@ +# ---> Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# UV +# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +#uv.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + diff --git a/README.md b/README.md new file mode 100644 index 0000000..f54f4c7 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# United_utilities_scrapper +