需要注意定位
如上图不是用span标签
而是a标签
实现点击头像登录
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://mail.qq.com/cgi-bin/loginpage?s=session_timeout&from=&r=f03641c94dcd060b6239ab8485791af4&tiptype=LOGIN_ERR_COOKIE_FORBIDDEN")
driver.switch_to.frame('login_frame')
driver.find_element_by_class_name('face').click()
实现账号密码登录
from selenium import webdriver
import time
def scroll(driver):
while True:
# 滑动之前的页面高度
document = driver.execute_script('return document.body.scrollHeight;')
time.sleep(2)
# 滑动页面
driver.execute_script(f'window.scrollTo(0,{
document})')
time.sleep(2)
# 滑动之后的页面高度
document2 = driver.execute_script('return document.body.scrollHeight;')
# 比较滑动前与滑动后的高度
if document == document2:
break
driver = webdriver.Firefox()
driver.get("https://mail.qq.com/cgi-bin/loginpage?s=session_timeout&from=&r=f03641c94dcd060b6239ab8485791af4&tiptype=LOGIN_ERR_COOKIE_FORBIDDEN")
scroll(driver)#由于登录界面有一部分在屏幕下面如果不先滚动上来则识别不了
time.sleep(2)
driver.switch_to.frame('login_frame'