刷视频的自动点击

from selenium import webdriver
import time
from selenium import webdriver  # 驱动浏览器

from selenium.webdriver.support.wait import WebDriverWait

browser = webdriver.Chrome()
wait = WebDriverWait(browser, 10)

try:
    browser.get('https://labsafe.nwafu.edu.cn/index.php')
    baidu_button_tag = browser.find_element_by_id("formExam")
    baidu_button_tag.click()  # 点击
    # wait.until(EC.presence_of_element_located((By.ID, '4')))
    time.sleep(1)
    baidu_input1_tag = browser.find_element_by_id("username")
    baidu_input1_tag.send_keys("####")
    baidu_input2_tag = browser.find_element_by_id("password")
    baidu_input2_tag.send_keys("@@@@@")
    baidu_button1_tag = browser.find_element_by_id("send-btn")
    baidu_button1_tag.click()
    browser.find_element_by_xpath('//*[@id="article"]/div[3]/div[2]/ul/li[2]').click()
    time.sleep(1)
    browser.find_element_by_xpath('//*[@id="article"]/div[3]/div[2]/div/div[2]/ul/li[1]/a').click()
    i=120
    time.sleep(1)
    while i:
        browser.find_element_by_xpath('//*[@id="dati"]/div[11]/input[2]').click()
        browser.find_element_by_xpath('//*[@id="dati"]/div[11]/input[2]').click()
        time.sleep(1)
        browser.find_element_by_xpath('//*[@id="dati"]/div[11]/input[1]').click()
        i=i-1

finally:
    time.sleep(5)
    # browser.close()  # 关闭浏览器

你可能感兴趣的:(python,爬虫)