Skip to content

Stop Clicking! Automate Your Daily Web Tasks with Python

Your morning routine of logging in, clicking buttons, and downloading reports can be automated. Build a robust "Daily Bot" using Playwright.

Stop Clicking! Automate Your Daily Web Tasks with Python
On this page
  1. Introduction
  2. Why Playwright over Selenium?
  3. The Scenario: "The Daily Report"
  4. Step 1: Setup & Login
  5. Step 2: Navigation & Interactions
  6. Step 3: Handling Downloads
  7. Going Headless (Background Mode)
  8. FAQ

Introduction

Do you log into the same portal every morning, click the same three buttons, download a CSV, and email it? Stop doing that.

In this guide, we're not just scraping data; we're interacting with the web. We'll build a robust script using Playwright (Python) to automate a full user workflow: Login, Dashboard Navigation, and File Download.

Why Playwright over Selenium?

Selenium has been around forever, but for modern web automation, Microsoft's Playwright is the new king.

Auto-Waiting: No more time.sleep(5). Playwright waits for elements to be actionable automatically.

Speed: It communicates directly with the browser engine, making it significantly faster.

Headless Mode: Runs invisible in the background by default.

Browser Contexts: Run multiple isolated sessions (like Incognito windows) instantly.

The Scenario: "The Daily Report"

The Mission

  1. Open the company portal login page.
  2. Enter username/password and click Login.
  3. Wait for the Dashboard to load.
  4. Navigate to the "Reports" section.
  5. Click "Download Daily CSV" and save it to a specific folder.

Step 1: Setup & Login

First, install Playwright: pip install playwright and playwright install.

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    # Launch browser (set headless=False to see it working)
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()

    # 1. Go to Login Page
    page.goto("https://portal.example.com/login")

    # 2. Fill Credentials
    page.fill("input#username", "my_email@company.com")
    page.fill("input#password", "super_secret_password")

    # 3. Click Login
    page.click("button[type='submit']")
    
    # Wait for URL to change (confirmation of login)
    page.wait_for_url("**/dashboard")
    print("Login Successful!")
    
    browser.close()

Step 2: Navigation & Interactions

Playwright is smart. If the menu takes 2 seconds to slide out, Playwright waits.

Navigating Menus

# Click the 'Reports' sidebar link
page.click("a#nav-reports")

# Wait for the reports table to appear
page.wait_for_selector("table.reports-list")

Step 3: Handling Downloads

Downloads can be tricky because they open native system dialogs. Playwright handles this gracefully with the expect_download context manager.

The Download Handler

# Start waiting for the download BEFORE clicking
with page.expect_download() as download_info:
    page.click("button#download-csv")

download = download_info.value

# Save it specifically where we want
download.save_as("C:/Reports/daily_report.csv")

print(f"Downloaded: {download.suggested_filename}")

Going Headless (Background Mode)

Once your script works, change headless=True. Now the script runs invisibly!

Visual Flow of the Automation Script

Visualizing the Login to Download Workflow

Key Takeaway

You can schedule this python script using Windows Task Scheduler or Cron (Linux) to run every morning at 8:00 AM. Your report will be ready before you even sip your coffee.

Frequently asked questions

Does this work on sites with 2FA?

It's harder. You would need to automate the OTP retrieval (from email API or authenticator secret) or save the 'browser state' (cookies) after logging in once manually.

Will I get banned?

If you run it once a day like a human, no. If you run it 10,000 times an hour, yes. Always respect rate limits.

Can I use this for specialized web apps?

Yes! Playwright works with any modern web app, including React, Angular, Vue, and Salesforce.

Keep reading

The Ultimate Selenium Python Guide: From Zero to HeroAutomation

The Ultimate Selenium Python Guide: From Zero to Hero

A comprehensive reference to Selenium WebDriver with Python. Master locators, waits, advanced interactions, headless mode, and best practices.

MD Kawsar· January 18, 2026 · 12 min read
Why Realtors adopt tech: 81% save time, 63% learning curveReal Estate

Why Realtors adopt tech: 81% save time, 63% learning curve

NAR's 2026 report: 81% of agents adopt tech to save time; 63% cite the learning curve. Based on 1,200 agents surveyed.

MD Kawsar· October 6, 2026 · 9 min read
Property tracker case study for 30 Florida zip codesReal Estate

Property tracker case study for 30 Florida zip codes

One South Florida tracker, 30 zip codes: 56,306 rows written, 12,336 repeats removed, 43,970 unique listings left.

MD Kawsar· October 5, 2026 · 10 min read

Want us to build this for you?

Tell us what data or workflow you need. We reply within a few hours.

Book a free call ↗