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


Python QNetworkCookieJar.setCookiesFromUrl方法代码示例

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


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

示例1: load_cookies

# 需要导入模块: from PyQt4.QtNetwork import QNetworkCookieJar [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkCookieJar import setCookiesFromUrl [as 别名]
def load_cookies():
    '''unpickle the cookie jar'''
    jar = QNetworkCookieJar()
    try:
        with open(join(homedir(), COOKIE_FILE)) as file:           
            cookies = []
            for name, value in pickle.load(file):
                cookies.append(QNetworkCookie(name, value))
            jar.setCookiesFromUrl(cookies, QUrl(COOKIE_URL))
    except IOError:
        pass # no cookie file is okay
    return jar
    
开发者ID:martinth,项目名称:pyg-music,代码行数:14,代码来源:cookie.py

示例2: setCookiesFromUrl

# 需要导入模块: from PyQt4.QtNetwork import QNetworkCookieJar [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkCookieJar import setCookiesFromUrl [as 别名]
 def setCookiesFromUrl(self, cookieList, url):
     if self.__read_only:
         return True
     resp = QNetworkCookieJar.setCookiesFromUrl(self, cookieList, url)
     if resp:
         self.emit(SIGNAL('cookieJarUpdated()'))
     return resp
开发者ID:Averroes,项目名称:raft,代码行数:9,代码来源:InMemoryCookieJar.py

示例3: set_cookies_from_url

# 需要导入模块: from PyQt4.QtNetwork import QNetworkCookieJar [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkCookieJar import setCookiesFromUrl [as 别名]
    def set_cookies_from_url(self, cookies, url):
        """ Reimplementation from base class. Prevents cookies from being set
        if not from whitelisted domains.

        """
        if ".".join(unicode(url.host()).split('.')[-2:]) not in self.allowed:
            ret = []
        else:
            ret = cookies
        if ret:
            log(format_cookie(url, ret))
        return QNetworkCookieJar.setCookiesFromUrl(self, ret, url)
开发者ID:aminembarki,项目名称:eilat,代码行数:14,代码来源:CookieJar.py

示例4: setCookiesFromUrl

# 需要导入模块: from PyQt4.QtNetwork import QNetworkCookieJar [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkCookieJar import setCookiesFromUrl [as 别名]
 def setCookiesFromUrl(self, cookieList, url):
     """
     Public method to set cookies for a URL.
     
     @param cookieList list of cookies to set (list of QNetworkCookie)
     @param url url to set cookies for (QUrl)
     @return flag indicating cookies were set (boolean)
     """
     if not self.__loaded:
         self.load()
     
     globalSettings = QWebSettings.globalSettings()
     if globalSettings.testAttribute(QWebSettings.PrivateBrowsingEnabled):
         return False
     
     host = url.host()
     eBlock = self.__isOnDomainList(self.__exceptionsBlock, host)
     eAllow = not eBlock and \
              self.__isOnDomainList(self.__exceptionsAllow, host)
     eAllowSession = not eBlock and \
                     not eAllow and \
                     self.__isOnDomainList(self.__exceptionsAllowForSession, host)
     
     addedCookies = False
     acceptInitially = self.__acceptCookies != self.AcceptNever
     if (acceptInitially and not eBlock) or \
        (not acceptInitially and (eAllow or eAllowSession)):
         # url domain == cookie domain
         soon = QDateTime.currentDateTime()
         soon = soon.addDays(90)
         for cookie in cookieList:
             lst = []
             if not (self.__filterTrackingCookies and \
                     cookie.name().startsWith("__utm")):
                 if eAllowSession:
                     cookie.setExpirationDate(QDateTime())
                 if self.__keepCookies == self.KeepUntilTimeLimit and \
                    not cookie.isSessionCookie and \
                    cookie.expirationDate() > soon:
                     cookie.setExpirationDate(soon)
                 lst.append(cookie)
                 if QNetworkCookieJar.setCookiesFromUrl(self, lst, url):
                     addedCookies = True
                 elif self.__acceptCookies == self.AcceptAlways:
                     # force it in if wanted
                     cookies = self.allCookies()
                     for ocookie in cookies[:]:
                         # does the cookie exist already?
                         if cookie.name() == ocookie.name() and \
                            cookie.domain() == ocookie.domain() and \
                            cookie.path() == ocookie.path():
                             # found a match
                             cookies.remove(ocookie)
                     
                     cookies.append(cookie)
                     self.setAllCookies(cookies)
                     addedCookies = True
     
     if addedCookies:
         self.__saveTimer.changeOccurred()
         self.emit(SIGNAL("cookiesChanged()"))
     
     return addedCookies
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:65,代码来源:CookieJar.py


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