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. PaddleOCRSharp,2022年,你来的晚了些,一款.NET离线使用的高精度OCR

    一款免费且离线的.NET使用的OCR,爱你又恨你!恨你来的太晚了. PaddleOCRSharp 本项目是一个基于百度飞桨的PaddleOCR的C++代码修改并封装的.NET的类库.包含文本识别.文本 ...

  2. 在 k8s 中的 jenkins 集成 sonarqube 实现代码质量检查

    不乱于心,不困于情,不畏将来,不念过往,如此安好 --<不宠无惊过一生>丰子恺 概述 关于在 k8s 中安装 jenkins 和 sornarqube 可以查看下面的文章: 在 k8s 中 ...

  3. TensorRT 开始

    TensorRT 是 NVIDIA 自家的高性能推理库,其 Getting Started 列出了各资料入口,如下: 本文基于当前的 TensorRT 8.2 版本,将一步步介绍从安装,直到加速推理自 ...

  4. List转换Map的三种方式

    1.for循环 ... 2.使用guava Map<Long, User> maps = Maps.uniqueIndex(userList, new Function<User, ...

  5. Android EditText不弹出输入法总结,焦点问题的总结

    看一个manifest中Activity的配置,如果这个页面有EditText,并且我们想要进入这个页面的时候默认弹出输入法,可以这样设置这个属相:android:windowSoftInputMod ...

  6. Android官方文档翻译 四 1.2Running Your App

    Running Your App If you followed the previous lesson to create an Android project, it includes a def ...

  7. 【刷题-LeetCode】307. Range Sum Query - Mutable

    Range Sum Query - Mutable Given an integer array nums, find the sum of the elements between indices ...

  8. 返回值String表示视图

    第一种:处理器方法返回String--表示逻辑视图名称(需配置视图解析器) 视图解析器: MyController类中: index.jsp中: 第二种:处理器方法方慧String,表示完整视图路径, ...

  9. 黑客是如何通过开放的Redis服务入侵服务器的

    0x00 简要说明 百度百科:Redis(Remote Dictionary Server ),即远程字典服务,是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-V ...

  10. ansible roles实践——安装nginx

    1.创建roles 在/etc/ansible/roles目录下 1.1 手动创建需要的目录 1.2 使用命令创建,用不到的目录可以创建为空目录,但不可以不创建. 创建目录[root@master] ...