python 模拟登陆163邮箱
作者:Kr1s77 时间:2021-08-03 09:30:11
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
def login():
acount_num = input('请输入账号:\n')
passwd_str = input('请输入密码:\n')
driver = webdriver.Edge()
url = 'http://mail.163.com/'
driver.get(url)
# 等待页面加载完成,出现可以点击到密码登录的button
wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.ID, 'lbNormal')))
driver.find_element_by_id('lbNormal').click()
# 使用CSSSelector正则匹配头部
elem = driver.find_element_by_css_selector("iframe[id^='x-URS-iframe']")
# 163登陆框是使用iframe进行嵌套的,所以需要先切换到该iframe
driver.switch_to.frame(elem)
account_el = driver.find_element_by_xpath('//input[@name="email"]')
account_el.clear()
account_el.send_keys(acount_num)
password_el = driver.find_element_by_xpath('//input[@name="password"]')
password_el.clear()
password_el.send_keys(passwd_str)
login_el = driver.find_element_by_xpath('//a[@id="dologin"]')
login_el.click()
time.sleep(10)
cur_cookies = driver.get_cookies()
return cur_cookies
if __name__ == '__main__':
login()
来源:https://github.com/Kr1s77/awesome-python-login-model
标签:python,模拟,登录,163,邮箱
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
9行Python3代码实现批量提取PDF文件的指定内容
2023-02-12 03:22:41
![](https://img.aspxhome.com/file/2023/8/88858_0s.png)
Python3内置json模块编码解码方法详解
2023-02-15 13:32:26
悟道Web标准:让W3C标准兼容终端
2009-10-11 16:40:00
php 进阶:实现无限分类第1/4页
2023-11-17 21:04:55
python图像填充与裁剪/resize的实现代码
2022-07-12 07:49:15
分享一个简单的python读写文件脚本
2022-11-21 20:03:00
python使用正则表达式替换匹配成功的组并输出替换的次数
2022-04-05 06:35:05
php5.4传引用时报错问题分析
2023-11-14 15:03:17
python标识符命名规范原理解析
2023-05-28 04:06:42
pytorch 求网络模型参数实例
2021-12-08 08:41:11
![](https://img.aspxhome.com/file/2023/3/103233_0s.jpg)
IE 下 href 的 BUG
2008-11-10 12:32:00
Python中selenium库的用法详解
2021-06-26 00:29:41
opencv python 傅里叶变换的使用
2022-07-27 14:55:03
![](https://img.aspxhome.com/file/2023/2/92472_0s.jpg)
Python插件机制实现详解
2021-08-28 06:55:30
![](https://img.aspxhome.com/file/2023/2/104832_0s.jpg)
python re.match()用法相关示例
2023-07-21 05:12:30
Python实现PS滤镜Fish lens图像扭曲效果示例
2022-02-01 05:25:02
![](https://img.aspxhome.com/file/2023/5/104935_0s.jpg)
python3+opencv生成不规则黑白mask实例
2023-10-06 11:01:25
![](https://img.aspxhome.com/file/2023/5/72995_0s.jpg)
WEB2.0网页制作标准教程(1)选择什么样的DOCTYPE
2007-11-13 12:57:00
CSS sprites图片拼合生成器
2007-10-15 12:25:00
Python采集C站热榜数据实战示例
2022-05-03 13:13:13