加载中...

一个自动填写问卷小程序


# -*- coding = utf-8 -*-
# @Time : 2022/11/2 12:39
# @Author : Lurume
# @File : 自动填写(edge.py
# @Software : PyCharm
import time

from selenium import webdriver
from selenium.webdriver.common.by import By

url = str(input('输入:'))# 输入问卷网址
option = webdriver.EdgeOptions()
option.add_argument('user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.26"')

option.add_argument('--disable-blink-features=AutomationControlled')
#option.add_experimental_option('excludeSwitches', ['enable-automation'])
option.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Edge(options=option)
driver.get(url)
time.sleep(0.1)

driver.find_elements(By.CLASS_NAME, 'ws-textarea__inner')[0].send_keys("***")       # 姓名
driver.find_elements(By.CLASS_NAME, 'ws-textarea__inner')[1].send_keys("15******75")# 填写电话号码
driver.find_elements(By.CLASS_NAME, 'ws-textarea__inner')[2].send_keys("10******1") # 学号
driver.find_elements(By.CLASS_NAME, 'ws-textarea__inner')[3].send_keys("20*******2")# QQ号

button = driver.find_elements(By.CLASS_NAME, 'ws-radio__input')[0]
driver.execute_script("arguments[0].click();", button) # 勾选按钮

bt = driver.find_elements(By.CLASS_NAME, 'ws-radio__input')[-1]
driver.execute_script("arguments[0].click();", bt)

以上代码是我在去年抢核酸志愿者时,利用selenium加上当时所掌握的一点点前端知识编写的,非常的简陋,但这是我第一次将代码实际应用起来,纪念一下。


文章作者: Lurume
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Lurume !
  目录