Python+selenium自动循环送贺卡
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自动循环送贺卡的更多相关文章
- Python+selenium自动循环扔QQ邮箱漂流瓶
Python代码如下: # coding=utf-8 from selenium import webdriver from time import sleep from random import ...
- Python+selenium自动循环发邮件
Python源代码如下: # coding=utf-8 from selenium import webdriver from time import sleep from random import ...
- Python + Selenium 自动发布文章(一):开源中国
https://blog.csdn.net/qq_28804275/article/details/80891949 https://blog.csdn.net/qq_28804275/article ...
- python+selenium自动测试之WebDriver的常用API(基础篇二)
本篇介绍一下python+selenium复杂操作的处理,基于python3.6,selenium3.141,详细资料介绍查看官方API文档,点击这里 一.常见特殊情况处理如iframe/弹窗处理 有 ...
- python+selenium自动测试之WebDriver的常用API(基础篇一)
基于python3.6,selenium3.141,详细资料介绍查看官方API文档,点击这里 一.对浏览器操作 driver = webdriver.Chrome() # 初始化chrome driv ...
- python selenium 自动登陆
#-*- coding:utf8 -*- # 导入selenium2中的webdriver库 from time import sleep from selenium import webdriver ...
- python selenium while 循环
while True: try: loadmore = browser.find_element_by_xpath('//div[@class="right"]/div[@clas ...
- [Python爬虫] Selenium自动访问Firefox和Chrome并实现搜索截图
前两篇文章介绍了安装,此篇文章算是一个简单的进阶应用吧!它是在Windows下通过Selenium+Python实现自动访问Firefox和Chrome并实现搜索截图的功能. [Pyth ...
- 开源you-get项目爬虫,以及基于python+selenium的自动测试利器
写在前面 爬虫和自动测试,对于python来说是最合适不过也是最擅长的. 开源的项目也很多,例如you-get项目https://github.com/soimort/you-get.盗链和爬虫神器. ...
随机推荐
- 简单的Dos 命令
1.1.如何操作DOS命令 开始---运行---输入cmd--回车 或者 Win + R ---运行---输入cmd--回车 1.2.基本命令 1. 命令:color f0 帮助:color ? 作用 ...
- Spring学习:简单实现一个依赖注入和循环依赖的解决
依赖注入 什么是依赖注入 使用一个会创建和查找依赖对象的容器,让它负责供给对象. 当a对象需要b对象时,不再是使用new创建,而是从容器中获取,对象与对象之间是松散耦合的关系,有利于功能复用. 依赖: ...
- 最新RabbitMQ安装指南2021.07
一.RabbitMQ入门及安装 1.入门及安装 01 概述 简单概述: RabbitMQ是一个开源的遵循 AMQP协议实现的基于 Erlang语言编写,支持多种客户端(语言),用于在分布式系统中存储消 ...
- vscode搜索高亮个性化设置
"workbench.colorCustomizations": { "editor.selectionHighlightBorder": "#1ED ...
- MATLAB中插值算法实现
%%%1.M文件%(1).以往少的程序可以在命令行窗口进行编码,但大量的程序编排到命令行窗口,%会有造成乱码的危险.(2).如果将命令编成程序存储在一个文件中(M文件),依次运行文件中的命令,则可以重 ...
- Ubuntu下使用VS Code创建Spring Boot工程
目的 我们将在Ubuntu桌面系统下,使用VS Code(Visual Studio Code)编辑器从零开始创建一个Spring Boot工程,并实现一个简单的RESTful风格接口.使用这套流程的 ...
- winSCP上传文件到服务器失败,提示permission denied,返回码3
1.查看sftp服务在你服务器的路径 cat /etc/ssh/sshd_config | grep sftp 2.在winSCP进行连接设置 设置好你的主机名.端口.用户名和密码,然后点击高级,点击 ...
- Git Push 免输 用户名和密码
前言 在大家使用github的过程中,一定会碰到这样一种情况,就是每次要push 和pull时总是要输入github的账号和密码,这样不仅浪费了大量的时间且降低了工作效率.在此背景下,本文在网上找了两 ...
- Struts2中的过滤器
过滤器: 过滤器可以处理用户的请求和程序响应的内容,可用于权限控制.编码转换的场合.过滤器是servlet规范中的一部分,不是只有Struts2有. 使用过滤器之前你得定义一个过 ...
- Apache中commons包的各种jar的功能说明
commons-logging.jar -----记录日志,通常和 log4j.jar共同使用 commons-beanutils.jar(1.1) 主要提供Bean的 ...