python selenium 实现自动输入信息报名

2022-11-22 08:13:35 浏览数 (1)

代码语言:javascript复制
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
import selenium.webdriver.common.keys  as keys
#技术由 奋斗少年 支持
'''创建谷歌浏览器对象'''
web=webdriver.Chrome()
'''打开北方科技学校官网'''
web.get('http://www.bf-shijiazhuang.com/?BD-SJZ-YD90010&Dzx20220321d319=cl1&bd_vid=7206926341750992549')
'''创建电话库'''
sd=['18347589093','18707865234','18794594937','18467853943','15257666693','18759461982','13567411322','13412434718','13672926840','18386115979','13906249986']
'''寻找输入手机号框'''
for i in sd:
    '''输入电话'''
    dd=web.find_element(by=By.XPATH,value='//*[@id="dian"]').send_keys(i)
    time.sleep(2)
    '''报名'''
    d=web.find_element(by=By.XPATH,value='//*[@id="tijiao"]').click()
    time.sleep(2)
    '''定位弹窗'''
    Alert = web.switch_to.alert
    time.sleep(2)
    '''确认弹窗'''
    Alert.accept()
    '''清空手机号'''
    web.find_element(by=By.XPATH, value='//*[@id="dian"]').clear()
    time.sleep(2)

0 人点赞