公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

1、思路

1.使用selenium登陆163邮箱

2.自动发送邮件到qq邮箱

2、完整代码

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver import ChromeOptions
import time

#除掉浏览器的识别验证
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])
option.add_experimental_option("detach", True)

driver = webdriver.Chrome(options=option)
driver.get('https://mail.163.com/')
#获取ifram
login_iframe = driver.find_element(By.XPATH,'//div[@class="loginWrap"]/div[@id="loginDiv"]/iframe')
#切换到ifram
driver.switch_to.frame(login_iframe)
#点击账号输入
user = driver.find_element(By.XPATH,'//div[@id="account-box"]/div[2]/input')
user.send_keys('chenjinming712@163.com')
#点击输入密码
passwd = driver.find_element(By.XPATH,'//div[@class="inputbox"]/div[2]/input[2]')
passwd.send_keys('xxxxxxx')
login = driver.find_element(By.XPATH,'//div[@class="f-cb loginbox"]/a')
#创建鼠标行为链
anctions = ActionChains(driver)
#输入账号
anctions.send_keys_to_element(user)
#输入密码
anctions.send_keys_to_element(passwd)
#点击登录
anctions.move_to_element(login).click()
#提交鼠标行为链
anctions.perform()
time.sleep(3)
# 点击写信
driver.find_elements(By.CLASS_NAME,"oz0")[1].click()
driver.switch_to.default_content()
# 收件人邮箱
driver.find_elements(By.TAG_NAME,"input")[3].send_keys("565667754@qq.com")

#主题
time.sleep(3)
driver.find_element(By.XPATH,'/html/body/div[2]/div[1]/div/div[1]/section/header/div[2]/div[1]/div/div/input').send_keys('test mail')

# 定位写信内容框架
driver.switch_to.frame(driver.find_element(By.CLASS_NAME,"App-editor-iframe"))
driver.find_element(By.CLASS_NAME,"nui-scroll").send_keys("你好呀!") # 信息内容

# 点击发送按钮
driver.switch_to.default_content()
driver.find_element(By.XPATH,'//div[@class="nui-toolbar-item"]/div/span[2]').click()
time.sleep(2)

# 关闭页面
driver.quit()

3、获取结果

 

 

如果您喜欢本文,就请动动您的发财手为本文点赞评论转发,让我们一起学习更多运维相关知识,最后请记得关注我。

分享到:
标签:python
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定