Prompt
How do I build a bot that logs into multiple websites and fills out forms?
Latest observation
Nov 6, 2026
OpenAI APIWeb search: off
Building a bot that logs into multiple websites and fills out forms is usually done with browser automation, but the right approach depends on whether you control those sites and what the forms are for.
First: a quick caution
- Make sure you have permission to automate the websites.
- Don’t bypass CAPTCHAs, MFA, rate limits, or access controls.
- If the sites provide an API, that’s usually better than automating the browser.
Common approaches
1) Use browser automation
Best when the sites are only available through the web UI.
Popular tools:
- Playwright: modern, reliable, works well across browsers
- Selenium: older, widely used
- Puppeteer: strong for Chrome/Chromium
Playwright is often the best choice for new projects.
Suggested architecture
A. Separate site configs
For each website, store:
- login URL
- form URL
- selectors for username/password fields, buttons, and form fields
- any special steps, like redirects or multi-page flows
B. Keep credentials secure
Use:
- environment variables
- a secret manager
- encrypted vault storage
Never hardcode passwords into the script.
C. Build a per-site handler
Each site may need its own logic:
- fill login form
- wait for navigation
- handle 2FA if allowed
- navigate to target form
- fill fields
- submit
- verify success
D. Add retries and logging
Track:
- login success/failure
- form submission status
- screenshots on error
- page HTML or error details for debugging
Example with Playwright in Python
from playwright.sync_api import sync_playwright
def fill_site_a(page, username, password, form_data):
page.goto("https://example.com/login")
page.fill("#username", username)
page.fill("#password", password)
page.click("button[type=submit]")
page.wait_for_load_state("networkidle")
page.goto("https://example.com/form")
page.fill("#first_name", form_data["first_name"])
page.fill("#last_name", form_data["last_name"])
page.fill("#email", form_data["email"])
page.click("button[type=submit]")
def main():
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
context = browser.new_context()
page = context.new_page()
fill_site_a(
page,
username="your_username",
password="your_password",
form_data={
"first_name": "Jane",
"last_name": "Doe",
"email": "jane@example.com"
}
)
browser.close()
if __name__ == "__main__":
main()
Handling multiple websites
Create a list of “site modules” or config entries:
sites = [
{
"name": "Site A",
"login_url": "https://sitea.com/login",
"form_url": "https://sitea.com/form",
"selectors": {
"username": "#username",
"password": "#password",
"submit": "button[type=submit]"
}
},
{
"name": "Site B",
"login_url": "https://siteb.com/signin",
"form_url": "https://siteb.com/apply",
"selectors": {
"username": "input[name='email']",
"password": "input[name='pass']",
"submit": "#login-btn"
}
}
]
Then loop through each site and call its handler.
Important practical issues
Login protection
- MFA may require a human step or approved integration
- Some sites rotate element IDs or use anti-bot measures
- Session cookies may expire, so you may need to log in each run
Form complexity
- Some forms have dynamic fields
- File uploads need special handling
- Dropdowns and checkboxes may require different methods than text inputs
Reliability
- Use explicit waits, not arbitrary sleeps
- Save screenshots when things fail
- Test each site individually before combining them
Recommended next step
If you want, I can help you design this in one of these ways:
- Python + Playwright starter project
- Node.js + Playwright starter project
- A config-driven framework for many sites
- Help for a specific website if you describe the login and form flow