国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python3+selenium實現126郵箱登陸并發送郵件功能

2020-02-16 00:50:11
字體:
來源:轉載
供稿:網友

本文實例為大家分享了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 Byimport 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,"http://span[text()='發送']")))wait.until(EC.visibility_of_element_located((By.XPATH,"http://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,"http://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_sourcelogout_link=driver.find_element_by_xpath("http://a[text()='退出']")time.sleep(3)assert u"登錄" in driver.page_source driver.quit()

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 康马县| 邛崃市| 潼关县| 库尔勒市| 察哈| 桑日县| 洪江市| 台安县| 改则县| 建宁县| 阳春市| 和田县| 唐山市| 司法| 南投市| 广河县| 曲靖市| 汕头市| 绍兴市| 清水河县| 石家庄市| 阳高县| 孝感市| 东光县| 石嘴山市| 彭州市| 庆城县| 金门县| 都兰县| 三门县| 苍梧县| 积石山| 慈溪市| 济源市| 资源县| 梅河口市| 鸡泽县| 福泉市| 金门县| 广西| 潞西市|