帝王谷资源网 Design By www.wdxyy.com
本文实例为大家分享了python3实现126邮箱登陆并发送邮件的具体代码,供大家参考,具体内容如下
基于selenium,使用chrome浏览器,完成126邮箱登陆并发送发邮件功能,暂时未封装。
from selenium import webdriver # 导入显示等待类 from selenium.webdriver.support.ui import WebDriverWait # 导入期望场景类 from selenium.webdriver.support import expected_conditions as EC # 导入By类 from selenium.webdriver.common.by import By import time #浏览器驱动放在了c:\\Python36\\Scripts目录下,无需指定参数 driver= webdriver.Chrome() driver.get("https://mail.126.com/") time.sleep(3) ####登陆 driver.switch_to.frame("x-URS-iframe") user_name = driver.find_element_by_xpath('//*[@name="email"]') #将xxxxxxx替换为自己的用户名 user_name.send_keys('xxxxxxx') pass_word = driver.find_element_by_xpath('//*[@name="password"]') #将11111111111替换为自己的密码 pass_word.send_keys('11111111111') button = driver.find_element_by_id("dologin") button.click() driver.switch_to.default_content() time.sleep(3) ####写邮件 wait = WebDriverWait(driver,10,0.2) ##wait.until(EC.visibility_of_element_located((By.XPATH,"//span[text()='发送']"))) wait.until(EC.visibility_of_element_located((By.XPATH,"//a[contains(text(),'退出')]"))) driver.find_element_by_xpath('//span[text()="写 信"]').click() driver.find_element_by_xpath('//input[@tabindex="1" and @role="combobox"]'). send_keys("1234h@qq.com") driver.find_element_by_xpath('//input[@tabindex="1" and @class="nui-ipt-input"]'). send_keys("测试邮件") driver.find_element_by_xpath('//input[@type="file"]').send_keys("f:\\b.txt") time.sleep(5) wait.until(EC.visibility_of_element_located((By.XPATH,"//span[text()='上传完成']"))) driver.switch_to.frame(driver.find_element_by_xpath('//iframe[@tabindex=1]')) driver.execute_script("document.getElementsByTagName('body')[0].innerHTML='<b>邮件的正文内容<b>;'") driver.switch_to.default_content() ##发送 driver.find_element_by_xpath('//span[text()="发送"]').click() time.sleep(5) assert '发送成功' in driver.page_source logout_link=driver.find_element_by_xpath("//a[text()='退出']") time.sleep(3) assert u"登录" in driver.page_source driver.quit()
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
帝王谷资源网 Design By www.wdxyy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
帝王谷资源网 Design By www.wdxyy.com
暂无评论...
更新日志
2024年10月25日
2024年10月25日
- 群星2013-青春缤纷辑压箱宝大公开3CD2[新加坡限量版][WAV整轨]
- 林育群.2013-BalladShow(日本版)【环球】【WAV+CUE】
- 陈加洛.1992-痛到感觉不到【宝丽金】【WAV+CUE】
- 群星.2023-宿命之敌电视剧原声带【韶愔音乐】【FLAC分轨】
- 東京事変-大発見[FLAC+CUE]
- 椎名林檎-三文ゴシップ[FLAC+CUE]
- 2024年08月04日
- 裘德《裘德「最后的水族馆」演唱会LIVE》[320K/MP3][228.89MB]
- 裘德《裘德「最后的水族馆」演唱会LIVE》[24bit 48kHz][FLAC/分轨][2.08G]
- 基因三重奏《如果你什么都不说 音乐会现场录音》[320K/MP3][145.37MB]
- 孟庭苇.1996-月亮说话(2020环球24KGOLD限量版)【上华】【WAV+CUE】
- 群星.1997-新艺宝优质音响系列·国语精选监听版【新艺宝】【WAV+CUE】
- 阿桑.2005-寂寞在唱歌(星外星引进版)【华研国际】【WAV+CUE】
- 基因三重奏《如果你什么都不说 音乐会现场录音》[FLAC/分轨][287.43MB]
- 蔡题谦《我爱你,却依然要看你走》[320K/MP3][88.65MB]