Python源代码如下:

# coding=utf-8
from selenium import webdriver
from time import sleep
from random import randint def auto_throw(target_qq, username, password):
"""自动循环送贺卡"""
driver = webdriver.Chrome()
driver.get("https://mail.qq.com")
driver.set_window_size(1100, 580)
sleep(1)
# 切换iframe表单
driver.switch_to.frame("login_frame")
driver.find_element_by_xpath('//*[@id="u"]').send_keys(username)
driver.find_element_by_xpath('//*[@id="p"]').send_keys(password)
driver.find_element_by_xpath('//*[@id="login_button"]').click()
sleep(1)
# 将表单切回到最外层
driver.switch_to.default_content()
sleep(2)
m = 0
while True:
try:
m += 1
driver.switch_to.default_content()
driver.find_element_by_xpath('//*[@id="folder_card"]').click() # 贺卡
sleep(2)
# 切换iframe表单
driver.switch_to.frame("mainFrame")
driver.find_element_by_xpath('//*[@id="preview_1072308"]/img').click() # 儿童节
# 将表单切回到最外层
driver.switch_to.default_content()
sleep(2)
driver.find_element_by_xpath('//div[@class="dialog_operate"]/a').click() # 发送
sleep(2)
driver.find_element_by_xpath('//a[@title="%s@qq.com"]'%target_qq).click()
sleep(1)
driver.find_element_by_xpath('//*[@id="GreetingCard_QMDialog_content"]').clear()
driver.find_element_by_xpath('//*[@id="GreetingCard_QMDialog_content"]').send_keys("第%d张贺卡发送成功!随机代号%d!"%(m,randint(10000,100000)))
sleep(2)
driver.find_element_by_xpath('//*[@id="GreetingCard_QMDialog_sendbtn"]').click() # 发送
print("第%d张贺卡发送成功!"%m)
sleep(2)
except:
print("送卡失败!")
sleep(2) if __name__ == '__main__':
print("--------自动循环送贺卡脚本--------")
target_qq = input("请输入对方qq号:")
username = input("输入你的QQ邮箱用户名:")
password = input("输入你的QQ邮箱登录密码:")
auto_throw(target_qq, username, password)

Python+selenium自动循环送贺卡的更多相关文章

  1. Python+selenium自动循环扔QQ邮箱漂流瓶

    Python代码如下: # coding=utf-8 from selenium import webdriver from time import sleep from random import ...

  2. Python+selenium自动循环发邮件

    Python源代码如下: # coding=utf-8 from selenium import webdriver from time import sleep from random import ...

  3. Python + Selenium 自动发布文章(一):开源中国

    https://blog.csdn.net/qq_28804275/article/details/80891949 https://blog.csdn.net/qq_28804275/article ...

  4. python+selenium自动测试之WebDriver的常用API(基础篇二)

    本篇介绍一下python+selenium复杂操作的处理,基于python3.6,selenium3.141,详细资料介绍查看官方API文档,点击这里 一.常见特殊情况处理如iframe/弹窗处理 有 ...

  5. python+selenium自动测试之WebDriver的常用API(基础篇一)

    基于python3.6,selenium3.141,详细资料介绍查看官方API文档,点击这里 一.对浏览器操作 driver = webdriver.Chrome() # 初始化chrome driv ...

  6. python selenium 自动登陆

    #-*- coding:utf8 -*- # 导入selenium2中的webdriver库 from time import sleep from selenium import webdriver ...

  7. python selenium while 循环

    while True: try: loadmore = browser.find_element_by_xpath('//div[@class="right"]/div[@clas ...

  8. [Python爬虫] Selenium自动访问Firefox和Chrome并实现搜索截图

    前两篇文章介绍了安装,此篇文章算是一个简单的进阶应用吧!它是在Windows下通过Selenium+Python实现自动访问Firefox和Chrome并实现搜索截图的功能.        [Pyth ...

  9. 开源you-get项目爬虫,以及基于python+selenium的自动测试利器

    写在前面 爬虫和自动测试,对于python来说是最合适不过也是最擅长的. 开源的项目也很多,例如you-get项目https://github.com/soimort/you-get.盗链和爬虫神器. ...

随机推荐

  1. [未完] Linux 4.4 USB —— spiflash模拟usb大容量存储设备 调试记录 Gadget Mass Stroage

    linux 4.4 USB Gadget Mass Stroage 硬件平台: licheepi nano衍生 调试记录 驱动信息 │ This driver is a replacement for ...

  2. 小程序onShareAppMessage有点迷

    小程序遇到的问题 起因 目前项目需求是分享时携带参数去进行裂变,但是在查看微信文档后发现有onShareAppMessage这个页面处理事件可以使用.事件可以使用return一个Object,用于自定 ...

  3. 微服务架构 | 3.4 HashiCorp Consul 注册中心

    目录 前言 1. Consul 基础知识 1.1 Consul 是什么 1.2 Consul 的特点 2. 安装并运行 Consul 服务器 2.1 下载 Consul 2.2 运行 Consul 服 ...

  4. VictoriaMerics学习笔记(2):核心组件

    核心组件 1. 单机版 victoria-metrics-prod 单一二进制文件 读写都在一个节点上 作者推荐单机版 特性 merge方式配置 通过HTTP协议提供服务 内存限制(防止OOM) 使用 ...

  5. 【记录一个问题】opencv中 cv::dft()与cv::ocl_dft()计算的结果相差较大

    以一个跟踪算法来测试: 使用cv::dft(), 矩阵未按照2次幂对齐,最终跟踪平均准确率 84.3% 使用cv::dft(),矩阵使用cv::copyMakeBorder对齐,最终跟踪平均准确率 8 ...

  6. cv::copyMakeBorder()中用0值对齐矩阵,方便后续加速傅里叶变换

    int M = cv::getOptimalDFTSize(mul_result.rows); // 获得最佳DFT尺寸,为2的次方 int N = cv::getOptimalDFTSize(mul ...

  7. centos下APUE 例程编译-解决报错与改写例子名字。

    首先是编译生成libapue.a的库文件.按照readme的说法很简单改个目录make一下就好,但是在centos下还是有错.通过下面这篇博文<<UNIX环境高级编程中的apue.h错误& ...

  8. 5种高大上的yml文件读取方式,你知道吗?

    原创:微信公众号 码农参上,欢迎分享,转载请保留出处. 在上一篇文章中,我们从源码角度分析了SpringBoot解析yml配置文件的全流程,那么我们今天就来点实战,总结一下除了烂大街的@Value和@ ...

  9. ansible command和shell的区别

    1.command模块不支持管道符和变量等,如果要使用这些,需要shell模块. 2.在使用ansible中的时候,默认的模块是-m command,从而模块的参数不需要填写,直接使用即可

  10. nginx二进制安装

    目录 一:二进制安装nginx 1.下载CentOS源 2.安装CentOS源 3.下载epel源(失败显示未找到命令) 4.解决依赖 5.安装Epel源 6.安装nginx 一:二进制安装nginx ...