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


Python cookies.Cookies类代码示例

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


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

示例1: authorize

    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,代码行数:31,代码来源:telus.py

示例2: authorize

    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,代码行数:35,代码来源:rogers.py

示例3: check_cookie

def check_cookie(handler, userId=None):
    cookies = Cookies(handler)
    if cookies.__contains__('sessionid') and memcache.get(cookies['sessionid']):
        sessionId=cookies['sessionid']
        userId=str(base64.b64decode(memcache.get(sessionId))).strip()
        memcache.set(sessionId, memcache.get(sessionId))
        return userId
    elif userId:
        uniqueId=str(uuid.uuid1())
        cookies['sessionid'] = uniqueId
        memcache.add(uniqueId, str(base64.b64encode(userId)))
        return userId
    return None
开发者ID:Divyaadz,项目名称:erp,代码行数:13,代码来源:authutil.py

示例4: authorizeDevice

    def authorizeDevice(self, streamProvider, mso_id, channel):
        """
        Authorise the device for a particular channel.

        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param mso_id the MSO identifier (eg: 'Rogers')
        @param channel the channel identifier
        """
        settings = Settings.instance().get('adobe')

        values = { 'resource_id' : channel,
                   'requestor_id' : streamProvider.getRequestorID(),
                   'signed_requestor_id' : streamProvider.getSignedRequestorID(),
                   'mso_id' : mso_id,
                   'authentication_token' : settings['AUTHN_TOKEN'],
                   'device_id' : streamProvider.getDeviceID(),
                   'userMeta' : '1' }

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

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.AUTHORIZE_URI, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return False
开发者ID:micahg,项目名称:plugin.video.cdncbl,代码行数:29,代码来源:adobe.py

示例5: deviceShortAuthorize

    def deviceShortAuthorize(self, streamProvider, mso_id):
        """
        Authorise for a particular channel... a second time.
        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param mso_id the MSO identifier (eg: 'Rogers')
        @return the session token required to authorise video the stream
        """
        settings = Settings.instance().get('adobe')

        values = { 'requestor_id' : streamProvider.getRequestorID(),
                   'signed_requestor_id' : streamProvider.getSignedRequestorID(),
                   'session_guid' : uuid.uuid4(),
                   'hashed_guid' : 'false',
                   'authz_token' : settings['AUTHZ_TOKEN'],
                   'mso_id' : mso_id,
                   'device_id' : streamProvider.getDeviceID() }

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

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.DEVICE_SHORT_AUTHORIZE, urllib.urlencode(values))
        except urllib2.URLError, e:
            print e.args
            return ''
开发者ID:micahg,项目名称:plugin.video.cdncbl,代码行数:28,代码来源:adobe.py

示例6: callback

    def callback(username, password):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
        opener.addheaders = [('User-Agent', urllib.quote(Sportsnet.USER_AGENT))]

        values = { 'callback' : 'mvpdSignInCallback',
                   'username' :  username,
                   'password' : password,
                   't' : str(int(time.time())) }
        try:
            resp = opener.open('https://now.sportsnet.ca/secure/mvpd/myrogers?'+urllib.urlencode(values))
        except:
            print "Unable to login with signinmvpd"
            return False

        res = resp.read()
        json_data  = re.search('mvpdSignInCallback\((.*?)\)', res, re.MULTILINE)
        if not json_data:
            return False

        jsres = json.loads(json_data.group(1))

        if not 'code' in jsres.keys():
            return True

        if jsres['code'] != 'loginsuccess':
            return False

        return True
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:29,代码来源:sportsnet.py

示例7: preAuthorize

    def preAuthorize(self, streamProvider, resource_ids):
        """
        Pre-authroize.  This _should_ get a list of authorised channels.

        @param streamProvider the stream provider (eg: the SportsnetNow
                              instance)
        @param resource_ids a list of resources to preauthorise
        @return a dictionary with each resource id as a key and boolean value
                indicating if the resource could be authorised
        """
        settings = Settings.instance().get('adobe')

        values = { 'authentication_token' : settings['AUTHN_TOKEN'],
                   'requestor_id' : streamProvider.getRequestorID() }

        value_str = urllib.urlencode(values)
        for resource_id in resource_ids:
            value_str += '&' + urllib.urlencode({ 'resource_id' : resource_id })

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

        opener.addheaders = [('User-Agent', urllib.quote(self.USER_AGENT))]

        try:
            resp = opener.open(self.PREAUTHORIZE_URI, value_str)
        except urllib2.URLError, e:
            print e.args
            return False
开发者ID:micahg,项目名称:plugin.video.cdncbl,代码行数:29,代码来源:adobe.py

示例8: login_messenger

    def login_messenger(self, driver):
        msg_driver = Cookies(driver)
        try:
            msg_driver.get_cookies()
            driver.refresh()
            time.sleep(4)

        except EOFError:
            username = driver.find_element_by_id("email")
            password = driver.find_element_by_id("pass")

            username.send_keys(self.email)
            password.send_keys(self.passwd)
            driver.find_element_by_name("login").click()
            time.sleep(4)
            msg_driver.log_cookies()
开发者ID:veljkoselakovic,项目名称:emoji-randomizer,代码行数:16,代码来源:CoreMSG.py

示例9: __init__

    def __init__(self, args):
        super(HttpScan, self).__init__(args)
        self.session = requesocks.session()

        adapters.DEFAULT_RETRIES = self.args.max_retries
        self.tor = None
        if self.args.tor:
            self.out.log("Enabling TOR")
            self.tor = Torify()
            self.session.proxies = {'http': 'socks5://127.0.0.1:9050',
                                    'https': 'socks5://127.0.0.1:9050'}
            if self.args.check_tor:
                # Check TOR
                self.out.log("Checking IP via TOR")
                rip, tip = self.tor.check_ip(verbose=True)
                if tip is None:
                    self.out.log('TOR is not working properly!', logging.ERROR)
                    exit(-1)

        if self.args.cookies is not None:
            if path.exists(self.args.cookies) and path.isfile(self.args.cookies):
                self.cookies = MozillaCookieJar(self.args.cookies)
                self.cookies.load()
            else:
                # self.out.log('Could not find cookie file: %s' % self.args.load_cookies, logging.ERROR)
                self.cookies = Cookies.from_request(self.args.cookies)
        else:
            self.cookies = None

        self.ua = UserAgent() if self.args.user_agent is None else self.args.user_agent
开发者ID:0x90,项目名称:futurescan,代码行数:30,代码来源:scan.py

示例10: completeBackgroundLogin

    def completeBackgroundLogin():
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open('https://sp.auth.adobe.com/adobe-services/completeBackgroundLogin')
        except urllib2.URLError, e:
            print e.args
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:8,代码来源:shawgo.py

示例11: authorize

    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,代码行数:46,代码来源:cogeco.py

示例12: _on_request

    def _on_request(self, adapter, request, **kwargs):
        match = self._find_match(request)
        # TODO(dcramer): find the correct class for this
        if match is None:
            error_msg = 'Connection refused: {0} {1}'.format(request.method,
                                                             request.url)
            response = ConnectionError(error_msg)
            response.request = request

            self._calls.add(request, response)
            raise response

        if 'body' in match and isinstance(match['body'], Exception):
            self._calls.add(request, match['body'])
            raise match['body']

        headers = {}
        if match['content_type'] is not None:
            headers['Content-Type'] = match['content_type']

        if 'callback' in match:  # use callback
            status, r_headers, body = match['callback'](request)
            if isinstance(body, six.text_type):
                body = body.encode('utf-8')
            body = BufferIO(body)
            headers.update(r_headers)

        elif 'body' in match:
            if match['adding_headers']:
                headers.update(match['adding_headers'])
            status = match['status']
            body = BufferIO(match['body'])

        response = HTTPResponse(
            status=status,
            reason=six.moves.http_client.responses[status],
            body=body,
            headers=headers,
            preload_content=False,
        )

        response = adapter.build_response(request, response)
        if not match.get('stream'):
            response.content  # NOQA

        try:
            resp_cookies = Cookies.from_request(response.headers['set-cookie'])
            response.cookies = cookiejar_from_dict(dict(
                (v.name, v.value)
                for _, v
                in resp_cookies.items()
            ))
        except (KeyError, TypeError):
            pass

        self._calls.add(request, response)

        return response
开发者ID:2rs2ts,项目名称:moto,代码行数:58,代码来源:responses.py

示例13: authorize

    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,代码行数:45,代码来源:shawgo.py

示例14: checkMSOs

    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,代码行数:18,代码来源:snnow.py

示例15: authGateway

    def authGateway(values, url):
        jar = Cookies.getCookieJar()
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

        try:
            resp = opener.open(url, urllib.urlencode(values))
        except urllib2.URLError, e:
            if e.reason[1] == "No address associated with hostname":
                return True
            return None
开发者ID:siuside,项目名称:plugin.video.snnow,代码行数:10,代码来源:telus.py


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