python自动登陆邮箱
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time,selenium
url = "https://mail.qq.com/"
path = "E:\\python_s\\chromedriver.exe" #goole引擎自己下载对应的版本
driver = webdriver.Chrome(executable_path=path)
driver.get(url)
# 最大化窗口
driver.maximize_window()
# 找到iframe
a = driver.find_element_by_id("login_frame")
# 切换进去
driver.switch_to.frame(a)
elem_user = driver.find_element_by_xpath("//input[@id='u']")
elem_user.clear
elem_user.send_keys(u"QQ号")
elem_password = driver.find_element_by_xpath("//input[@id='p']")
elem_password.clear
elem_password.send_keys(u"QQ密码")
# 以下三种回车登陆
elem_password.send_keys(Keys.RETURN)
# driver.find_element_by_id('loginBtn').click()
# driver.find_element_by_id('loginBtn').submit()
time.sleep(10)
driver.close()
driver.quit()