Survey Completer Bot 2021 May 2026
import openai openai.api_key = "your-key"
def generate_answer(question_type, question_text=""): if question_type == "radio": return random.choice(["Option A", "Option B", "Option C"]) elif question_type == "checkbox": return random.sample(["Opt1", "Opt2", "Opt3"], k=random.randint(1,2)) elif question_type == "text_field": if "email" in question_text.lower(): return fake.email() elif "name" in question_text.lower(): return fake.name() else: return fake.word() elif question_type == "text_area": return "This is an auto-generated response." elif question_type == "dropdown": return "Option 2" else: return None def fill_survey(page): questions = page.locator(".question-container").all() # adjust selector for q in questions: q_text = q.inner_text() q_type = detect_question_type(q) answer = generate_answer(q_type, q_text) if q_type == "radio": q.locator(f"input[value='answer']").click() elif q_type == "checkbox": for val in answer: q.locator(f"input[value='val']").click() elif q_type == "text_field": q.locator("input").fill(answer) elif q_type == "text_area": q.locator("textarea").fill(answer) elif q_type == "dropdown": q.locator("select").select_option(label=answer) survey completer bot
page.click("button[type='submit']") while page.locator(".error-message").count() > 0: # fix errors (e.g., missed required fields) fill_missing_fields(page) page.click("button[type='submit']") 5. Advanced: AI-Powered Natural Answers Instead of random choices, use GPT to generate context-aware answers: import openai openai
