from selenium.webdriver import Chrome
import time
# 1.下载selenium
# 2.将驱动放在python解释器文件夹中
web = Chrome()
web.get("https://www.douyu.com/")
time.sleep(2)
web.find_element_by_xpath('//*[@id="js-header"]/div/div/div[3]/div[8]').click()
time.sleep(2)
# 切换到<iframe> 内嵌页面
web.switch_to.frame('login-passport-frame')
web.find_element_by_xpath('//*[@id="loginbox"]/div[2]/div[1]/div[2]').click()
web.find_element_by_xpath('//*[@id="loginbox"]/div[3]/div[2]/div/form/div[1]/div/input').send_keys('')
web.find_element_by_xpath('//*[@id="loginbox"]/div[3]/div[2]/div/form/div[3]/input[1]').send_keys('')
web.find_element_by_xpath('//*[@id="loginbox"]/div[3]/div[2]/div/form/div[6]/input').click()
time.sleep(20)
目前未解决验证码问题,后续通过cookie绕过验证码登录