Podlipodcast player Webplayer

CyberCode Academy

CyberCode Academy

Course 40 - Web Scraping with Python | Episode 42: Web Authentication and Automated Form Input Submission

CyberCode Academy · Aug 22, 2026 · 20:20

0:0020:20

Listen in the Podli app 🎧

Follow your favourite podcasts, listen offline and in the car with CarPlay and Android Auto, and always pick up where you left off. Free to try.

This episode is essentially about turning “login-protected websites” into programmable sessions and then controlling full form workflows like a real user.🔐 Core IdeaModern scraping stops being “download HTML” and becomes:“Authenticate → maintain session → interact → extract”This is the foundation of scraping anything behind a login wall.🍪 1. Session Cookies (Staying Logged In)🧠 What they are:
Without them:
🐍 How requests handles itYou use a session object:session = requests.Session() Why this matters:
🔥 Key insight:A session object = a “fake browser memory”🧾 2. CSRF Tokens (Hidden Security Gate)🧠 What they are:
Usually found in:
🕵️ How scraping handles it:
  1. Request login page
  2. Extract CSRF token from HTML
  3. Include it in POST request
Example flow:# Step 1: get page r = session.get(login_url) # Step 2: extract token (XPath / parsing) token = extract_token(r.text) # Step 3: submit login session.post(login_url, data={ "username": "...", "password": "...", "csrf": token }) 🔥 Key insight:CSRF tokens force scrapers to behave like real browsers that “see” the page first🧭 3. Selenium for UI InteractionOnce login flows become JavaScript-heavy or interactive, requests is not enough.So Selenium is used for:real browser simulation🔘 4. Handling Form Controls🔵 Radio Buttons
Action:
☑️ Checkboxes
Action:
📋 Dropdown MenusHandled using Selenium’s Select class:Options:
Example logic:from selenium.webdriver.support.ui import Select dropdown = Select(element) dropdown.select_by_visible_text("Option A") 🧠 5. Real Login Automation FlowThis episode combines everything into a full pipeline:Step-by-step:
  1. Open login page (Selenium or requests)
  2. Extract CSRF token (if exists)
  3. Fill credentials
  4. Submit form
  5. Maintain session (cookies)
  6. Access protected pages
  7. Extract data
⚙️ 6. Element Location StrategyTo interact with UI elements, you rely on:
🚨 7. Key Concept ShiftThis episode moves you from:Simple scraping:
To authenticated automation:
🔥 Final TakeawayThe real skill here is:reconstructing the entire user authentication lifecycle in codeOnce you can:
You can access:
If you want, I can next:


You can listen and download our episodes for free on more than 10 different platforms:
https://linktr.ee/cybercode_academy

Episodes: CyberCode Academy

PodliGet the free Podli app
↓ App