当前位置: 首页>>代码示例>>Python>>正文


Python CookieJar.set_cookie方法代码示例

本文整理汇总了Python中_clientcookie.CookieJar.set_cookie方法的典型用法代码示例。如果您正苦于以下问题:Python CookieJar.set_cookie方法的具体用法?Python CookieJar.set_cookie怎么用?Python CookieJar.set_cookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_clientcookie.CookieJar的用法示例。


在下文中一共展示了CookieJar.set_cookie方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_cookie

# 需要导入模块: from _clientcookie import CookieJar [as 别名]
# 或者: from _clientcookie.CookieJar import set_cookie [as 别名]
    def set_cookie(self, cookie):
        if cookie.discard:
            CookieJar.set_cookie(self, cookie)
            return

        def set_cookie(cur):
            # XXX
            # is this RFC 2965-correct?
            # could this do an UPDATE instead?
            row = self._row_from_cookie(cookie, cur)
            name, unused, domain, path = row[1:5]
            cur.execute("""\
DELETE FROM moz_cookies WHERE host = ? AND path = ? AND name = ?""",
                        (domain, path, name))
            cur.execute("""\
INSERT INTO moz_cookies VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
""", row)
        self._transaction(set_cookie)
开发者ID:BillTheBest,项目名称:Community-Zenpacks,代码行数:20,代码来源:_firefox3cookiejar.py

示例2: set_cookie

# 需要导入模块: from _clientcookie import CookieJar [as 别名]
# 或者: from _clientcookie.CookieJar import set_cookie [as 别名]
 def set_cookie(self, cookie):
     if self.delayload:
         self._delayload_domain(cookie.domain)
     CookieJar.set_cookie(self, cookie)
开发者ID:ppizarror,项目名称:korektor,代码行数:6,代码来源:_msiecookiejar.py

示例3: load_cookie_data

# 需要导入模块: from _clientcookie import CookieJar [as 别名]
# 或者: from _clientcookie.CookieJar import set_cookie [as 别名]
    def load_cookie_data(self, filename,
                         ignore_discard=False, ignore_expires=False):
        """Load cookies from file containing actual cookie data.

        Old cookies are kept unless overwritten by newly loaded ones.

        You should not call this method if the delayload attribute is set.

        I think each of these files contain all cookies for one user, domain,
        and path.

        filename: file containing cookies -- usually found in a file like
         C:\WINNT\Profiles\joe\Cookies\[email protected][1].txt

        """
        now = int(time.time())

        cookie_data = self._load_cookies_from_file(filename)

        for cookie in cookie_data:
            flags = cookie["FLAGS"]
            secure = ((flags & 0x2000) != 0)
            filetime = (cookie["HIXP"] << 32) + cookie["LOXP"]
            expires = epoch_time_offset_from_win32_filetime(filetime)
            if expires < now:
                discard = True
            else:
                discard = False
            domain = cookie["DOMAIN"]
            initial_dot = domain.startswith(".")
            if initial_dot:
                domain_specified = True
            else:
                # MSIE 5 does not record whether the domain cookie-attribute
                # was specified.
                # Assuming it wasn't is conservative, because with strict
                # domain matching this will match less frequently; with regular
                # Netscape tail-matching, this will match at exactly the same
                # times that domain_specified = True would.  It also means we
                # don't have to prepend a dot to achieve consistency with our
                # own & Mozilla's domain-munging scheme.
                domain_specified = False

            # assume path_specified is false
            # XXX is there other stuff in here? -- e.g. comment, commentURL?
            c = Cookie(0,
                       cookie["KEY"], cookie["VALUE"],
                       None, False,
                       domain, domain_specified, initial_dot,
                       cookie["PATH"], False,
                       secure,
                       expires,
                       discard,
                       None,
                       None,
                       {"flags": flags})
            if not ignore_discard and c.discard:
                continue
            if not ignore_expires and c.is_expired(now):
                continue
            CookieJar.set_cookie(self, c)
开发者ID:ppizarror,项目名称:korektor,代码行数:63,代码来源:_msiecookiejar.py


注:本文中的_clientcookie.CookieJar.set_cookie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。