當前位置: 首頁>>代碼示例>>Python>>正文


Python CookieManager.from_cookie_list方法代碼示例

本文整理匯總了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)))
開發者ID:fangjintang1989,項目名稱:grab,代碼行數:10,代碼來源:grab_cookies.py

示例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)))
開發者ID:julia-bikova,項目名稱:grab,代碼行數:10,代碼來源:grab_cookies.py

示例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)
開發者ID:julia-bikova,項目名稱:grab,代碼行數:9,代碼來源:grab_cookies.py

示例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'])
開發者ID:Kuznitsin,項目名稱:grab,代碼行數:10,代碼來源:base.py

示例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"])
開發者ID:fangjintang1989,項目名稱:grab,代碼行數:7,代碼來源:grab_cookies.py

示例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'])
開發者ID:julia-bikova,項目名稱:grab,代碼行數:7,代碼來源:grab_cookies.py


注:本文中的grab.cookie.CookieManager.from_cookie_list方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。