This Python bot automatically fills out Google Forms by reading questions and providing answers based on a predefined mapping of questions to answers.
- Automatically detects and fills various question types:
- Text fields
- Radio buttons
- Checkboxes
- Dropdown menus
- Supports multi-page forms
- Uses fuzzy matching to match questions with answers
- Provides logging for debugging
- Supports headless operation
- Python 3.7+
- Google Chrome browser
- ChromeDriver (automatically downloaded via webdriver-manager)
- Clone this repository
- Install the required packages:
pip install -r requirements.txtpython google_forms_bot.py <form_url> <answers_file> [--headless]form_url: The URL of the Google Form to fillanswers_file: Path to a JSON file containing question-answer mappings--headless: Optional flag to run the browser in headless mode
python google_forms_bot.py "https://docs.google.com/forms/d/e/.../viewform" sample_answers.json --headlessfrom google_forms_bot import GoogleFormsBot
# Create a bot instance
bot = GoogleFormsBot(headless=True)
# Define answers as a dictionary
answers = {
"What is your name?": "John Doe",
"What is your email?": "john@example.com"
}
# Fill a form
bot.fill_form("https://docs.google.com/forms/d/e/.../viewform", answers_dict=answers)
# Close the browser when done
bot.close()The answers file should be a JSON file with questions as keys and answers as values:
{
"What is your name?": "John Doe",
"What is your email address?": "johndoe@example.com",
"How would you rate our service?": "Excellent",
"Which features do you use most?": ["Email", "Calendar"], // For checkboxes
"Please select your preferred contact method": "Email", // For radio buttons
"Comments": "This is a great product!",
"default": "Default answer" // Used when no specific answer is found
}- The bot navigates to the specified Google Form URL
- It scans the page for questions using Selenium
- For each question, it matches the question text with the provided answers using fuzzy matching
- It fills the appropriate input field based on the question type
- For multi-page forms, it navigates to the next page
- Finally, it submits the form
- The bot uses fuzzy matching to match questions with answers, so exact text matching is not required
- Be respectful when using this tool and ensure you have permission to fill the forms
- Google Forms may have anti-automation measures, so results may vary
- This tool is for educational purposes and legitimate use only
- If the bot fails to detect questions, make sure the form is publicly accessible
- Some Google Forms may have additional security measures that prevent automation
- Ensure Chrome and ChromeDriver are properly installed/accessible
- Check the logs in
google_forms_bot.logfor debugging information