本文整理匯總了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)
示例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)
示例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)
示例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)
示例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
示例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)