python selenium模拟登录163邮箱和QQ空间
最近在看python网络爬虫,于是我想自己写一个邮箱和QQ空间的自动登录的小程序,
下面以登录163邮箱和QQ空间和为例:
了解到在Web应用中经常会遇到frame/iframe 表单嵌套页面的应用,WebDriver 只能在一个页面上对元素识别与定位,对于frame/iframe 表单内嵌页面上的元素无法直接定位。这时就需要通过switch_to.frame()方法将当前定位的主体切换为frame/iframe 表单的内嵌页面中

# -*- coding: utf-8 -*-
"""
Created on Fri Aug 31 2018
@author: chenlinlab
"""
from selenium import webdriver
from time import sleep
options = webdriver.ChromeOptions()
options.add_argument('disable-infobars')
driver = webdriver.Chrome(chrome_options=options)
driver.maximize_window()
#163 email login
driver.get('http://mail.163.com/')
sleep(1)
driver.switch_to.frame("x-URS-iframe")
driver.find_element_by_name("email").clear()
driver.find_element_by_name("email").send_keys('Your163EmailName')
driver.find_element_by_name("password").clear()
driver.find_element_by_name("password").send_keys('Your163EmailPassword')
driver.find_element_by_id("dologin").click()
sleep(10)
#qq zone login
driver.get('http://qzone.qq.com')
sleep(1)
driver.switch_to_frame('login_frame')
driver.find_element_by_id('switcher_plogin').click()
driver.find_element_by_id('u').clear()
driver.find_element_by_id('u').send_keys('YourQQ')
driver.find_element_by_id('p').clear()
driver.find_element_by_id('p').send_keys('YourQQPassword')
driver.find_element_by_id('login_button').click()
python selenium模拟登录163邮箱和QQ空间的更多相关文章
- python selenium模拟登陆163邮箱。
selenium是可以模拟浏览器操作. 有些爬虫是异步加载的,通过爬取网页源码是得不到需要的内容.所以可以模拟浏览器去登陆该网站进行爬取操作. 需要安装selenium通过pip install xx ...
- 使用Python+Selenium模拟登录QQ空间
使用Python+Selenium模拟登录QQ空间爬QQ空间之类的页面时大多需要进行登录,研究QQ登录规则的话,得分析大量Javascript的加密解密,这绝对能掉好几斤头发.而现在有了seleniu ...
- 九、Python+Selenium模拟登录
研究QQ登录规则的话,得分析大量Javascript的加密解密,比较耗时间.自己也是练习很少,短时间成功不了.所以走了个捷径. Selenium是一个WEB自动化测试工具,它运行时会直接实例化出一个浏 ...
- [Python爬虫] Selenium实现自动登录163邮箱和Locating Elements介绍
前三篇文章介绍了安装过程和通过Selenium实现访问Firefox浏览器并自动搜索"Eastmount"关键字及截图的功能.而这篇文章主要简单介绍如何实现自动登录163邮箱,同时 ...
- selenium模拟登录豆瓣和qq空间
selenium模拟登录豆瓣和qq空间今天又重新学习了下selenium,模拟登录豆瓣,发现设置等待时间真的是很重要的一步,不然一直报错:selenium.common.exceptions.NoSu ...
- python+selenium模拟京东登录后台
python+selenium模拟京东登录后台 import json from time import sleep from selenium import webdriver #from sele ...
- selenium登录163邮箱,得到cookie,requests后续请求
1.场景 很多时候登录操作是比较复杂的,因为存在各种反爆破操作,以及为了安全性提交数据都会存在加密.如果要完全模拟代码去实现登录操作是比较复杂,并且该网站后续更新了登录安全相关功能,那么登录的模拟操作 ...
- 4 使用Selenium模拟登录csdn,取出cookie信息,再用requests.session访问个人中心(保持登录状态)
代码: # -*- coding: utf-8 -*- """ Created on Fri Jul 13 16:13:52 2018 @author: a " ...
- Selenium自动化发送163邮箱
自动化发送163邮件 方法一: import time import datetime from selenium import webdriver from selenium.webdriver.s ...
随机推荐
- 记一次使用mybatis进行like 模糊查询遇到的问题
"bdate like '#{date}%' and ..." 最开始这样写的· 将传入的参数和%用单引号包起来,但是这会报错 java.sql.SQLException: Par ...
- Java中的构造器与垃圾回收
构造器 在我们初始化对象时,如果希望设置一些默认值,那么就可以使用构造器,在Java中,构造器使用和类同名的名字且没有返回值,如下 class Test{ private String name; T ...
- piplinedb 安装配置
piplinedb不能使用root用户操作,提前建好用户 [root@yzh-jkb-privatization /]# useradd steven [root@yzh-jkb-privatizat ...
- 我的MQ笔记
1.安装IBM MQ 1.1.安装先决条件: (1)WebSphere Eclipse Platform V3.01 (2)为Windows域用户配置WebSphere MQ用户 1.2.安装程 ...
- 【原】Solr入门之概念和安装
Apache Solr 是Apache Lucene项目的开源企业搜索平台.其主要功能包括全文检索.命中标示.分面搜索.动态聚类.数据库集成,以及富文本(如Word.PDF)的处理.Solr是高度可扩 ...
- Linux常用基本命令:uniq-去重复
uniq命令 作用:输出或者忽略文件中的重复行 格式: uniq [option] [file|stdin] ghostwu@dev:~/linux/uniq$ cat ghostwu.txt 192 ...
- 微信小程序 折叠效果
<view class='help'> <view class='help_item'> <view class='title' data-index='1' catch ...
- [TJOI2015]弦论
我们先求出该字符串的\(SA\)和\(Ht\) 然后分类讨论 \(T=0\)时,每次去掉\(Ht\)往后扫就行 \(T=1\)时,我们考虑\(lcp\)对答案的影响 既然用到\(lcp\),那就要用\ ...
- js-ES6学习笔记-Iterator
1.遍历器(Iterator)是一种接口,为各种不同的数据结构提供统一的访问机制.任何数据结构只要部署Iterator接口,就可以完成遍历操作(即依次处理该数据结构的所有成员). 2.Iterator ...
- 【代码笔记】iOS-自定义alertView
一,效果图. 二,代码. ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewContro ...