运行打印信息:
YOUDAO_MOBILE_ACCESS_TYPE -> 1
_PREF_ANONYUSER__MYTH -> aGFzbG9nZ2VkPXRydWU=
OUTFOX_SEARCH_USER_ID -> -1046383847@218.17.158.115
JSESSIONID -> abc7qSE_SBGsVgnVLBvcu
key-aaaaaaa -> value-bbbb # 这一条是我们自己添加的
通过博客园登陆来分析cookie
#coding=utf-8
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.get(http://passport.cnblogs.com/login.aspx?ReturnUrl=http://www.cnblogs.com/fnng/admin/EditPosts.aspx)
time.sleep(3)
driver.maximize_window() # 浏览器全屏显示
#通过用户名密码登陆
driver.find_element_by_id("tbUserName").send_keys("fnngj")
driver.find_element_by_id("tbPassword").send_keys("123456")
#勾选保存密码
driver.find_element_by_id("chkRemember").click()
time.sleep(3)
#点击登陆按钮
driver.find_element_by_id("btnLogin").click()
#获取cookie信息并打印
cookie= driver.get_cookies()
print cookie
time.sleep(2)
driver.close()
运行打印信息:
#第一次执行信息
>>>
[{u'domain': u'.cnblogs.com', u'name': u'.DottextCookie', u'value': u'C709F15A8BC0B3E8D9AD1F68B371053849F7FEE31F73F1292A150932FF09A7B0
D4A1B449A32A6B24AD986CDB05B9998471A37F39C3B637E85E481AA986D3F8C187D7708028F9D
4ED3B326B46DC43B416C47B84D706099ED1D78B6A0FC72DCF948DB9D5CBF99D7848FDB78324',
u'expiry': None, u'path': u'/', u'secure': False}]
>>>
#第二次执行信息
>>>
[{u'domain': u'.cnblogs.com', u'name': u'.DottextCookie', u'value': u'5BB735CAD62E99F8CCB9331
C32724E2975A0150D199F4243AD
19357B3F99A416A93B2E803F4D5C9D065429713BE8B5DB4ED
760EDCBAF492EABE2158B3A6FBBEA2B95C4DA3D2EFEA
DACC3247040906F1462731F652199E2A8BEFD8A9B6AAE87CF3059A3CAEB9AB0D8B1B7AD2A',
u'expiry': 1379502502, u'path': u'/', u'secure': False}]
>>>