python3 小实践(一)——selenium获取的cookie传递
from selenium import webdriver
from time import sleep
import requests
import pickle
#获取登录后的cookies
class get_cookie1: def __init__(self, url): self.url = url def get_cookie2(self): driver = webdriver.Chrome()
r = driver.get(self.url)
driver.find_element_by_xpath("//input[@name='userName']").send_keys('admin')
driver.find_element_by_xpath("//input[@name='password']").send_keys('')
driver.find_element_by_xpath("//input[@id='btnlogin']").click()
sleep(10) list_cookies= driver.get_cookies() print(list_cookies)
cookie={}
# 转换dict调用
for item in list_cookies:
cookie[item['name']]=item['value']
print(cookie) cookie= driver.get_cookies()
#print(cookie) self.cookie = cookie #print(self.cookie) return self.cookie
if __name__ =='__main__':
c = get_cookie1("url")
c.get_cookie2()
通过selenium提取的cookie转换一下格式就可以直接调用
python新人,代码写的有点挫,给自己获取的新知识点标个记
python3 小实践(一)——selenium获取的cookie传递的更多相关文章
- python3+selenium获取列表某一列的值
python3+selenium获取列表某一列的值 我们在坐自动化测试时,我们可能不想单纯的想验证一个选项卡,我们让脚本随机选择一个选项进行接下来的操作.例如我们想获取列表某一列的某一个数据(随机的) ...
- Python3+Selenium获取session和token供Requests使用教程
一.背景说明 之前写了一款简单的api模糊测试工具,之前系统可以使用http Base认证现在改成session形式并加上了token. 最简单的改造方法,是自己先在浏览器手动登录,然后提取出sess ...
- Python3.x:selenium获取iframe内嵌页面的源码
Python3.x:selenium获取iframe内嵌页面的源码 前言 在一些网页中经常会看到ifrmae/frame标签,iframe是嵌入式框架一般用来在已有的页面中嵌入另一个页面,当一个元素在 ...
- selenium webdriver(6)---cookie相关操作
介绍selenium操作cookie之前,先简单介绍一下cookie的基础知识 cookie cookie一般用来识别用户身份和记录用户状态,存储在客户端电脑上.IE的cookie文件路径(win7) ...
- python3 web测试模块selenium
selenium是一个用于web应用程序测试工具,selenium测试直接运行在浏览器中,就像真正的用户在操作一样,支持的浏览器包括IE(7,8,9,10,11),mozilla firefox,sa ...
- Python网络爬虫笔记(四):使用selenium获取动态加载的内容
(一) 说明 上一篇只能下载一页的数据,第2.3.4....100页的数据没法获取,在上一篇的基础上修改了下,使用selenium去获取所有页的href属性值. 使用selenium去模拟浏览器有点 ...
- Selenium入门13 cookie的增删改查
cookie的增删改查: 查询:get_cookies()查询所有cookie,get_cookie(cookie的name)获取单个cookie 删除:delete_cookie(cookie的na ...
- Python3+Selenium3+webdriver学习笔记11(cookie处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记11(cookie处理)'''from selenium im ...
- 几个小实践带你快速上手MindSpore
摘要:本文将带大家通过几个小实践快速上手MindSpore,其中包括MindSpore端边云统一格式及华为智慧终端背后的黑科技. MindSpore介绍 MindSpore是一种适用于端边云场景的新型 ...
随机推荐
- 说说DBA职责和目标
数据库管理员(Database Administrator,简称DBA),是从事管理和维护数据库管理系统(DBMS)的相关工作人员的统称,他属于运维工程师的一个分支,主要负责业务数据库从设计.测试到部 ...
- Jmeter--JDBC请求(sqlserver)
做JDBC请求,首先要了解这个JDBC对象是什么,然后寻找响应的数据库连接URL和数据库驱动. 数据库URL:jdbc:sqlserver://200.99.197.190:1433;database ...
- HDU 1250 Hat's Fibonacci(大数相加)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1250 Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Ot ...
- Using Lookup Tables to Accelerate Color Transformations
转自:http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html In feature-film visual-effects ...
- 让NSArray数组中每个对象都调用的方法
1. [array valueForKey:@"title"]; //Returns an array containing the results of invoking val ...
- webapi 获取json数据
一般的我们可以直接使用参数来接受,这个就不多介绍了 [HttpGet] public IHttpActionResult Test2([FromUri]string name) { object ob ...
- 一致性模型(consistency model)
比如下面的例子: 一行X值在节点M和节点N上有副本 客户端A在节点M上写入行X的值 一段时间后,客户端B在节点N上读取行X的值 一致性模型所要做的就是决定客户端B能否看到客户端A写的值.一致性模型分为 ...
- KMP初探
最近在做字符串匹配,沉迷于indexof无法自拔,但是考虑到大数据处理的时间复杂度,决定研究一波KMP. 在这我就不讲什么原理了,转自: https://www.cnblogs.com/zhangti ...
- chromium之message_pump_win之三
上一篇分析MessagePumpForUI,参考chromium之message_pump_win之二 MessagePumpForIO,同MessagePumpForUI,也是要实现三个函数 // ...
- chromium之ScopedNSAutoreleasePool浅析
上代码,看看注释 ScopedNSAutoreleasePool只有Mac系统特有的,也可以理解为OC特有的函数, 其他系统为空实现 // On the Mac, ScopedNSAutorele ...