Selenium-Python-自动化-网易邮箱发送邮件

刚接触python,大佬们轻喷 (0_0)

#coding:gbk

from selenium import webdriver
from time import sleep
browser=webdriver.Chrome()
url="https://mail.163.com/"

browser.get(url)
sleep(3)
browser.switch_to_frame("x-URS-iframe")
print("进入登录表单")
sleep(3)
a="/html/body/div[2]/div[2]/div[2]/form/div/div[1]/div[2]/input"
b="/html/body/div[2]/div[2]/div[2]/form/div/div[3]/div[2]/input[2]"
c="/html/body/div[2]/div[2]/div[2]/form/div/div[8]/a"
browser.find_element_by_xpath(a).clear()
browser.find_element_by_xpath(a).send_keys("user")
print("输入账号")
browser.find_element_by_xpath(b).clear()
browser.find_element_by_xpath(b).send_keys("password")
print("输入密码")
browser.find_element_by_xpath(c).click()
print("点击登录")
sleep(3)
d="/html/body/div[1]/nav/div[1]/ul/li[2]/span[2]"
browser.find_element_by_xpath(d).click()
print("进入发送邮件页面")
sleep(1)
e="/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[1]/div[1]/div/div[2]/div/input"
browser.find_element_by_xpath(e).send_keys("[email protected]")
print("填写收信人邮箱")
f="/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[2]/div[1]/div/div/input"
browser.find_element_by_xpath(f).send_keys("逮到你了,这是一个BUG!")
print("填写邮件标题")
sleep(2)
h="/html/body/div[2]/div[1]/div[2]/header/div/div[1]/div/span[2]"
browser.find_element_by_xpath(h).click()
print("发送邮件")
sleep(5)
browser.close()
print("关闭浏览器")

 

你可能感兴趣的:(Selenium-Python-自动化-网易邮箱发送邮件)