本文整理匯總了Python中grab.cookie.CookieManager.from_cookie_list方法的典型用法代碼示例。如果您正苦於以下問題:Python CookieManager.from_cookie_list方法的具體用法?Python CookieManager.from_cookie_list怎麽用?Python CookieManager.from_cookie_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類grab.cookie.CookieManager
的用法示例。
在下文中一共展示了CookieManager.from_cookie_list方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_from_cookie_list
# 需要導入模塊: from grab.cookie import CookieManager [as 別名]
# 或者: from grab.cookie.CookieManager import from_cookie_list [as 別名]
def test_from_cookie_list(self):
cookie = create_cookie("foo", "bar", self.server.address)
mgr = CookieManager.from_cookie_list([cookie])
test_cookie = [x for x in mgr.cookiejar if x.name == "foo"][0]
self.assertEqual(cookie.name, test_cookie.name)
mgr = CookieManager.from_cookie_list([])
self.assertEqual(0, len(list(mgr.cookiejar)))
示例2: test_from_cookie_list
# 需要導入模塊: from grab.cookie import CookieManager [as 別名]
# 或者: from grab.cookie.CookieManager import from_cookie_list [as 別名]
def test_from_cookie_list(self):
cookie = create_cookie('foo', 'bar')
mgr = CookieManager.from_cookie_list([cookie])
test_cookie = [x for x in mgr.cookiejar if x.name == 'foo'][0]
self.assertEqual(cookie.name, test_cookie.name)
mgr = CookieManager.from_cookie_list([])
self.assertEqual(0, len(list(mgr.cookiejar)))
示例3: test_pickle_serialization
# 需要導入模塊: from grab.cookie import CookieManager [as 別名]
# 或者: from grab.cookie.CookieManager import from_cookie_list [as 別名]
def test_pickle_serialization(self):
cookie = create_cookie('foo', 'bar')
mgr = CookieManager.from_cookie_list([cookie])
dump = pickle.dumps(mgr)
mgr2 = pickle.loads(dump)
self.assertEqual(list(mgr.cookiejar)[0].value,
list(mgr2.cookiejar)[0].value)
示例4: load_config
# 需要導入模塊: from grab.cookie import CookieManager [as 別名]
# 或者: from grab.cookie.CookieManager import from_cookie_list [as 別名]
def load_config(self, config):
"""
Configure grab instance with external config object.
"""
self.config = copy_config(config, self.mutable_config_keys)
if 'cookiejar_cookies' in config['state']:
self.cookies = CookieManager.from_cookie_list(config['state']['cookiejar_cookies'])
示例5: test_get_item
# 需要導入模塊: from grab.cookie import CookieManager [as 別名]
# 或者: from grab.cookie.CookieManager import from_cookie_list [as 別名]
def test_get_item(self):
cookie = create_cookie("foo", "bar", self.server.address)
mgr = CookieManager.from_cookie_list([cookie])
self.assertEqual("bar", mgr["foo"])
self.assertRaises(KeyError, lambda: mgr["zzz"])
示例6: test_get_item
# 需要導入模塊: from grab.cookie import CookieManager [as 別名]
# 或者: from grab.cookie.CookieManager import from_cookie_list [as 別名]
def test_get_item(self):
cookie = create_cookie('foo', 'bar')
mgr = CookieManager.from_cookie_list([cookie])
self.assertEqual('bar', mgr['foo'])
self.assertRaises(KeyError, lambda: mgr['zzz'])