python splinter
from splinter.browser import Browser
with Browser() as b:
for url,name in web:
b.visit(url)
b.fill('Password','password')
button=b.find_by_id('loginBtn')
button.click()
t=b.find_by_id('FreeSpaceId')
print name,t.text
tab=b.find_by_id('login-table')
ti=tab.first.find_by_xpath('tbody/tr/td/input')
ti[0].fill('username')
ti[1].fill('password')
button=b.find_by_text('Login')
button.click()
firefox代理
driver:https://github.com/mozilla/geckodriver/releases
proxy_settings={'network.proxy.type': 1,
'network.proxy.no_proxies_on':'172.0.0.0/8,10.0.0.0/8,localhost,127.0.0.0/8,::1',
'network.proxy.http':'172.1.1.1','network.proxy.http_port':8080,
'network.proxy.ssl':'172.1.1.1','network.proxy.ssl_port':8080}
b=Browser('firefox',profile_preferences=proxy_settings)
chrome代理
driver:http://chromedriver.storage.googleapis.com/index.html
https://sites.google.com/a/chromium.org/chromedriver/-
from splinter.driver.webdriver.chrome import Options, Chrome
chrome_options = Options()
chrome_options.add_argument('--proxy-server=http://%s' % PROXY)
b=Browser('chrome');b.driver=Chrome(chrome_options=chrome_options)
#--no-proxy-server
#--proxy-auto-detect
#--proxy-server=<scheme>=<uri>[:<port>][;...] | <uri>[:<port>] | "direct://"
##--proxy-server="http=foopy:80;ftp=foopy2"
##--proxy-server="foopy:8080"
## --proxy-server="direct://" will cause all connections to not use a proxy.
#--proxy-bypass-list=(<trailing_domain>|<ip-address>)[:<port>][;...]
##--proxy-server="foopy:8080" --proxy-bypass-list="*.google.com;*foo.com;127.0.0.1:8080"
#--proxy-pac-url=<pac-file-url> #selenium
from selenium import webdriver PROXY = "23.23.23.23:3128" # IP:PORT or HOST:PORT chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=http://%s' % PROXY) chrome = webdriver.Chrome(chrome_options=chrome_options)
chrome.get("http://whatismyipaddress.com")
如使用
b=Browser('chrome',chrome_options=chrome_options)
需要修改库中的chrome.py
if 'chrome_options' in kwargs:
options = kwargs.get('chrome_options', Options())
del kwargs['chrome_options']
else:
options = Options()
python splinter的更多相关文章
- python+splinter实现12306网站刷票并自动购票流程
python+splinter实现12306网站刷票并自动购票流程 通过python+splinter,实现在12306网站刷票并自动购票流程(无法自动识别验证码). 此类程序只是提高了12306网站 ...
- Python splinter 环境搭建
今天无意间看到了splinter. Splinter是一个使用Python开发的开源Web应用测试工具.它可以帮你实现自动浏览站点和与其进行交互. Splinter对已有的自动化工具(如:Seleni ...
- python splinter chromedriver下载地址(国内可用)
http://chromedriver.storage.googleapis.com/index.html
- 简单的Python 火车抢票程序
当你想查询一下火车票信息的时候,你还在上12306官网吗?或是打开你手机里的APP?下面让我们来用Python写一个命令行版的火车票查看器, 只要在命令行敲一行命令就能获得你想要的火车票信息!如果你刚 ...
- python代码实现抢票助手
一. 代码使用Python+Splinter开发,Splinter是一个使用Python开发的开源Web应用测试工具,它可以帮你实现自动浏览站点和与其进行交互. 二. 安装好Python 3或2都可以 ...
- splinter(python操作浏览器魔魁啊)
from splinter import Browser def main(): browser = Browser() browser.visit('http://google.com') brow ...
- python学习之——splinter使用
开始学习使用splinter工具了,目前是摸索中,先熟悉splinter工具的使用方法~~ 实现功能: 打开firefox浏览器->www.baidu.com->输入关键词 python, ...
- python学习之——splinter介绍
Splinter是什么: 是一个用 Python 编写的 Web 应用程序进行验收测试的工具. Splinter执行的时候会自动打开你指定的浏览器,访问指定的URL,然后你所开发的模拟的任何行为,都会 ...
- Python自动化测试工具Splinter简介和使用实例
Splinter 快速介绍 官方网站:http://splinter.cobrateam.info/ 官方介绍: Splinter is an open source tool for testing ...
随机推荐
- [python学习] 介绍python的property,以及为什么要用setter,一个小栗子
python中的property是比较好用的. 先来一段代码 #-*- coding:utf-8 -*- class C(object): status_dict = { 1: 'accept', 2 ...
- ViewState提交后丢失,竟然是OnInit搞的鬼
提交后报错,断点看ViewStat值没有了.排查半天完全不知道怎么回事. 百度搜索了下ViewState提交丢失.然后CSDN一个帖子说的半拉子话提点了我. 然后想到我经常重写这些函数.以前怎么没遇到 ...
- 在linux下写一只优雅的爬虫---优雅的获取沈航所有学生的个人信息
一:ubuntu下安装python集成环境pycharm以及免费激活 安装 首先去下载最新的pycharm 2016.2.3,进行安装.可以直接在官网下载.选择自己所对应的版本 PyCharm 的激活 ...
- Fiddler测试WebApi的Post方法报错
标题头要加 Content-Type: application/json,Request Body中写json数组.
- WPS for Linux(ubuntu)字体缺失解决办法(转)
原文:http://www.cnblogs.com/liangml/p/5969404.html 启动WPS for Linux后,出现提示"系统缺失字体" . 出现提示的原因是因 ...
- 学习计划-----java初级工程师
目标: 1.具备扎实的JAVA基础,对数据结构.基本算法熟练掌握,并具备基本的算法设计能力. 2.前台:精通JSP/Servlet.HTML.JavaScript.Ajax.Jquery, XML.J ...
- Rsa加解密Java、C#、php通用代码 密钥转换工具
之前发了一篇"TripleDes的加解密Java.C#.php通用代码",后面又有项目用到了Rsa加解密,还是在不同系统之间进行交互,Rsa在不同语言的密钥格式不一样,所以过程中主 ...
- 编程模式之装饰模式(Decorator)
装饰模式由四个角色组成:抽象组件角色,抽象装饰者角色,具体组件角色,具体装饰者角色. 抽象组件角色:给出一个抽象接口,以规范"准备接受附加功能"的对象. 抽象装饰者角色:持有一个组 ...
- Net accounts命令
Net accounts 将用户帐户数据库升级并修改所有帐户的密码和登录请求. 语法 net accounts [/forcelogoff:{minutes | no}] [/minpwlen:len ...
- seaJS循环依赖的解决原理
seajs模块的六个状态. var STATUS = { 'FETCHING': 1, // The module file is fetching now. 模块正在下载中 'FETCHED': ...