selenium+python的163自动写邮件脚本
来源:互联网 发布:阿里云视频播放器sdk 编辑:程序博客网 时间:2024/06/09 23:10
来自: http://www.cnblogs.com/siashero/
最近在学习selenium,去selenium中文论坛的时候看到一篇网友写的163自动写邮件的脚本。
于是仿照着写了一个。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from
selenium
import
webdriver
driver
=
webdriver.Firefox()
#open 163 mail
driver.get(
"http://mail.163.com/"
)
assert
"163"
in
driver.title
#fill in the username
username
=
driver.find_element_by_id(
"idInput"
)
username.clear()
username.send_keys(
"xxx"
)
#fill in the password
passwd
=
driver.find_element_by_id(
"pwdInput"
)
passwd.clear()
passwd.send_keys(
"xxx"
)
#login
login
=
driver.find_element_by_id(
"loginBtn"
)
login.click()
driver.implicitly_wait(
10
);
#write mail
write
=
driver.find_element_by_id(
"_mail_component_92_92"
)
write.click()
#file the address of the receiver
address
=
driver.find_element_by_class_name(
"nui-editableAddr-ipt"
)
address.send_keys(
"xxx@163.com"
)
driver.implicitly_wait(
10
);
#write the title
title
=
driver.find_element_by_id(
"objComposeSubject"
)
title.send_keys(
"test_hero"
)
#write the content
content
=
driver.find_element_by_class_name(
"APP-editor-iframe"
)
content.click()
content.send_keys(
"this is a test mail,from hero!"
)
#send
send_father
=
driver.find_element_by_class_name(
"nui-toolbar-item"
)
send
=
send_father.find_element_by_class_name(
"nui-btn-text"
)
send.click()
driver.implicitly_wait(
1000000
);
driver.close()
稍微解释下:
1.在login和write之间插入了一次等待,driver.implicitly_wait(10),是为了等待页面完全打开,不然此时无法找到write按钮,脚本就报错。
2.在最后的发送send.click()和关闭driver.close()之间再次插入一次较长的延时,这是因为根据网速的不同,发送邮件完成的时间也不同,如果尚未发送完成、停留在写信界面的话,直接执行driver.close(),163会弹窗提示是否立刻页面,导致浏览器无法正常关闭。加入了延时,就是为了等待邮件发送完成,此时再关闭浏览器,可以正常退出。
0 0
- selenium+python的163自动写邮件脚本
- Python自动发送邮件的脚本源码
- selenium+python自动登录脚本
- 怎样开始写第一个基于python的selenium脚本
- Python--脚本自动发送邮件
- python写的简单发送邮件的脚本
- Python+selenium创建自动执行命令脚本
- python应用最多的场景还是web快速开发、爬虫、自动化运维:写过简单网站、写过自动发帖脚本、写过收发邮件脚本、写过简单验证码识别脚本。
- 【Python学习笔记】-自动发送邮件脚本
- 自己用Python写的iOS项目自动打包脚本
- 自己用Python写的iOS项目自动打包脚本
- 发送邮件的python脚本
- svn commit-email自动发送邮件乱码问题的解决,以及自己写svn同步邮件脚本
- python写爬虫6-selenium的使用
- 自动下载openstack社区邮件的脚本
- 一个python的邮件发送脚本,自动,定时,可以附件发送,抄送,附有说明文件
- 一个python的邮件发送脚本,自动,定时,可以附件发送,抄送
- [selenium]实现自动登录163邮箱并发送邮件
- JSTL JSP标准标签库的配置
- 动态代理和静态代理的区别
- 窦靖童手缠绷带秀英俊侧脸 网友直呼帅哭
- @RequestMapping 用法详解之地址映射
- VC6.0中无法使用打开按钮,无法添加已有的文件
- selenium+python的163自动写邮件脚本
- U-Boot 编译(嵌入式U-BOOT,kernel编译)
- android获取应用程序大小,缓存数据信息
- android精确绘制文字位置的方法
- Android中处理崩溃异常
- 为 Drupal 7 构建一个新主题
- oracle comment on的用法
- 基于模糊集理论的一种图像二值化算法的原理、实现效果及代码
- 使用WTL的Wizard直接创建出来的工程修改步骤,使编译通过