from selenium import webdriver
from time import sleep
driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
driver.add_cookie({'name': 'BAIDUID', 'value': 'ASKMLJIH'})
driver.add_cookie({'name': 'BDUSS', 'value': 'UHUIHIU'})
sleep(3)
driver.refresh()
cookie 操作的几种方法
1.get_cookies():获取所有 cookies
2.driver.get_cookie(name):获取指定 name 的 cookie:
3.清除指定 cookie:delete_cookie()
4.delete_all_cookies():清除所有 cookies
5.add_cookie(cookie_dict):添加 cookie 的值
python爬虫之selenium-介绍和安装
python爬虫之selenium-浏览器操作方法
python爬虫之selenium-元素的定位
python爬虫之selenium--Xpath定位
python爬虫之selenium--iframe
python爬虫之selenium--单选下拉列表
python爬虫之selenium--鼠标操作
python爬虫之selenium--键盘操作
python爬虫之selenium--等待的三种方式
python爬虫之selenium--多窗口操作
python爬虫之selenium--操作JS弹框
python爬虫之selenium--上传文件
python爬虫之selenium--浏览器窗口截图
python爬虫之selenium--加载浏览器配置
python爬虫之selenium--表格和复选框的定位
python爬虫之selenium--获取HTML源码断言和URL地址
python爬虫之selenium--设置浏览器的位置和高度宽度
python爬虫之selenium--页面元素相关的操作
python爬虫之selenium--浏览器滚动条操作
python爬虫之selenium--拖拽页面元素
python爬虫之selenium--页面元素是否可见和可操作
python爬虫之selenium--高亮显示正在操作的元素
python爬虫之selenium--更改标签的属性值
python爬虫之selenium--单选框和复选框的操作
python爬虫之selenium--cookie操作
python爬虫之selenium--记录日志信息
转自:https://www.cnblogs.com/zouzou-busy/p/11219901.html