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


Python Cookies.saveCookieJar方法代码示例

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


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

示例1: authorize

# 需要导入模块: from cookies import Cookies [as 别名]
# 或者: from cookies.Cookies import saveCookieJar [as 别名]
    def authorize(streamProvider, username, password):
        """
        Perform authorization with Rogers

        @param streamProvider the stream provider object. Needs to handle the 
                              getAuthURI.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri = streamProvider.getAuthURI('Rogers')

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))#,
                                      #urllib2.HTTPHandler(debuglevel=1),
                                      #urllib2.HTTPSHandler(debuglevel=1))

        try:
            resp = opener.open(uri)
        except:
            print "Unable get OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        viewstate = re.search('<input.*__VIEWSTATE.*?value=\"(.*?)\".*?>', html, re.MULTILINE)
        if not viewstate:
            return None

        validation = re.search('<input.*__EVENTVALIDATION.*?value=\"(.*?)\".*?>', html, re.MULTILINE)
        if not validation:
            return None

        return Rogers.getOAuthToken(username, password, viewstate.group(1), validation.group(1), resp.url)
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:37,代码来源:rogers.py

示例2: authorize

# 需要导入模块: from cookies import Cookies [as 别名]
# 或者: from cookies.Cookies import saveCookieJar [as 别名]
    def authorize(streamProvider, username, password):
        """
        Perform authorization with Telus

        @param streamProvider the stream provider object. Needs to handle the 
                              getAuthURI.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri = streamProvider.getAuthURI('telus_auth-gateway_net')

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(uri)
        except:
            print "Unable get Telus OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        values = parseForm(['SAMLRequest', 'RelayState'], html)
        action = values.pop('action')
        if values == None:
            print "Form parsing failed in authorize"
            return None

        return Telus.getBookend(username, password, values, action)
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:33,代码来源:telus.py

示例3: authorize

# 需要导入模块: from cookies import Cookies [as 别名]
# 或者: from cookies.Cookies import saveCookieJar [as 别名]
    def authorize(streamProvider, username, password):
        """
        Perform authorization with Cogeco

        @param streamProvider the stream provider object.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri =  streamProvider.getAuthURI("Cogeco")

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))#,
                                      #urllib2.HTTPHandler(debuglevel=1),
                                      #urllib2.HTTPSHandler(debuglevel=1))

        # TODO: move this into a method that can be reused.. multiple calls..
        try:
            resp = opener.open(uri)
        except:
            print "Unable to redirect to auth page."
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        # TODO: this could be made a function to to parse and return the value based on an expression
        action = re.search('<form.*?action=\"(.*?)"', html, re.MULTILINE)
        if not action:
            print "Unable to find action form"
            return None
        action = action.group(1)

        saml = re.search('<input.*?name=\"SAMLRequest\".*?value=\"(.*?)\"', html, re.MULTILINE)
        if not saml:
            print "Unable to find SAML requst."
            return None
        saml = saml.group(1)

        relay = re.search('<input.*?name=\"RelayState\".*?value=\"(.*?)\"', html, re.MULTILINE)
        if not relay:
            print "Unable to find relay state."
            return None
        relay = relay.group(1)

        return Cogeco.postAuthSaml(username, password, saml, relay, action)
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:48,代码来源:cogeco.py

示例4: authorize

# 需要导入模块: from cookies import Cookies [as 别名]
# 或者: from cookies.Cookies import saveCookieJar [as 别名]
    def authorize(streamProvider, username, password):
        """
        Perform authorization with ShawGo

        @param streamProvider the stream provider object. Needs to handle the 
                              getAuthURI.
        @param username the username to authenticate with
        @param password the password to authenticate with
        """

        uri = streamProvider.getAuthURI('ShawGo')

        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))#,
                                      #urllib2.HTTPHandler(debuglevel=1),
                                      #urllib2.HTTPSHandler(debuglevel=1))

        try:
            resp = opener.open(uri)
        except:
            print "Unable get OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        html = resp.read()

        action = re.search('<form.*?action=\"(.*?)"', html, re.MULTILINE)
        if not action:
            print "Unable to find action form"
            return None
        action = action.group(1)

        saml = re.search('<input.*?name=\"SAMLRequest\".*?value=\"(.*?)\"', html, re.MULTILINE)
        if not saml:
            print "Unable to find SAML requst."
            return None
        saml = saml.group(1)

        relay = re.search('<input.*?name=\"RelayState\".*?value=\"(.*?)\"', html, re.MULTILINE)
        if not relay:
            print "Unable to find relay state."
            return None
        relay = relay.group(1)

        return ShawGo.getAuthn(username, password, saml, relay, action)
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:47,代码来源:shawgo.py

示例5: checkMSOs

# 需要导入模块: from cookies import Cookies [as 别名]
# 或者: from cookies.Cookies import saveCookieJar [as 别名]
    def checkMSOs(self):
        """
        Check the available MSOs. We don't actually use anything from this
        request other than the cookies returned.
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [("User-Agent", urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.AUTHORIZED_MSO_URI)
        except:
            print "Unable get OAUTH location"
            return None
        Cookies.saveCookieJar(jar)

        mso_xml = resp.read()
        return None
开发者ID:micahg,项目名称:plugin.video.cdncbl,代码行数:20,代码来源:snnow.py

示例6:

# 需要导入模块: from cookies import Cookies [as 别名]
# 或者: from cookies.Cookies import saveCookieJar [as 别名]
        @param url the entitlement URL
        """
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        values = {'adobeRequestSaml' : saml,
                  'relayState' : relay,
                  'username' : username,
                  'password' : password,
                  'IdpAdapterid' : idp }

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
        Cookies.saveCookieJar(jar)

        html = resp.read()

        action = re.search('<form.*?action=\"(.*?)"', html, re.MULTILINE)
        if not action:
            print "Unable to find action form"
            return None
        action = action.group(1)

        relay = re.search('<input.*?name=\"RelayState\".*?value=\"(.*?)\"', html, re.MULTILINE)
        if not relay:
            print "Unable to find relay state."
            return None
        relay = relay.group(1)
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:32,代码来源:shawgo.py


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