【Selenium8】cookie处理

coding=utf-8
from selenium import webdriver
import time
driver=webdriver.Firefox()
driver.get('http://www.baidu.com')
cookie=driver.get_cookies()   #获取cookie信息
print cookie
driver.delete_all_cookies() #删除所有cookie
driver.add_cookie({'name':'XXXXXX','value':'XXXXXX'}) #添加一组cookie键值对
for cookie in driver.get_cookies():
print '%s--->%s'%(cookie['name'],cookie['value'])
driver.delete_cookie('CookieName')  #通过CookieName删除特定cookie
time.sleep(2)
driver.quit()
posted @ 2014-04-07 19:44  junezhang  阅读(300)  评论(0编辑  收藏  举报