Python cookielib.LWPCookieJar() Examples
The following are 30
code examples of cookielib.LWPCookieJar().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cookielib
, or try the search function
.
Example #1
Source File: yahoo.py From yahoo-group-archiver with MIT License | 7 votes |
def init_cookie_jar(cookie_file=None, cookie_t=None, cookie_y=None, cookie_euconsent=None): cookie_jar = LWPCookieJar(cookie_file) if cookie_file else RequestsCookieJar() if cookie_file and os.path.exists(cookie_file): cookie_jar.load(ignore_discard=True) if args.cookie_t: cookie_jar.set_cookie(create_cookie('T', cookie_t)) if cookie_y: cookie_jar.set_cookie(create_cookie('Y', cookie_y)) if cookie_euconsent: cookie_jar.set_cookie(create_cookie('EuConsent', cookie_euconsent)) if cookie_file: cookie_jar.save(ignore_discard=True) return cookie_jar
Example #2
Source File: 18 github_login.py From Python-Spider with Apache License 2.0 | 6 votes |
def __init__(self): # url self.loginUrl = 'https://github.com/login' self.postUrl = 'https://github.com/session' self.profileUrl = 'https://github.com/settings/profile' # 设置请求头 self.headers = { 'Referer': 'https://github.com/', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36', 'Host': 'github.com' } # 设置session self.session = requests.session() # 生成github_cookie文件 self.session.cookies = cookielib.LWPCookieJar(filename='github_cookie')
Example #3
Source File: test_cookielib.py From BinderFilter with MIT License | 6 votes |
def test_bad_magic(self): from cookielib import LWPCookieJar, MozillaCookieJar, LoadError # IOErrors (eg. file doesn't exist) are allowed to propagate filename = test_support.TESTFN for cookiejar_class in LWPCookieJar, MozillaCookieJar: c = cookiejar_class() try: c.load(filename="for this test to work, a file with this " "filename should not exist") except IOError, exc: # exactly IOError, not LoadError self.assertEqual(exc.__class__, IOError) else: self.fail("expected IOError for invalid filename") # Invalid contents of cookies file (eg. bad magic string) # causes a LoadError.
Example #4
Source File: test_cookielib.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_bad_magic(self): from cookielib import LWPCookieJar, MozillaCookieJar, LoadError # IOErrors (eg. file doesn't exist) are allowed to propagate filename = test_support.TESTFN for cookiejar_class in LWPCookieJar, MozillaCookieJar: c = cookiejar_class() try: c.load(filename="for this test to work, a file with this " "filename should not exist") except IOError, exc: # exactly IOError, not LoadError self.assertEqual(exc.__class__, IOError) else: self.fail("expected IOError for invalid filename") # Invalid contents of cookies file (eg. bad magic string) # causes a LoadError.
Example #5
Source File: test_cookielib.py From oss-ftp with MIT License | 6 votes |
def test_bad_magic(self): from cookielib import LWPCookieJar, MozillaCookieJar, LoadError # IOErrors (eg. file doesn't exist) are allowed to propagate filename = test_support.TESTFN for cookiejar_class in LWPCookieJar, MozillaCookieJar: c = cookiejar_class() try: c.load(filename="for this test to work, a file with this " "filename should not exist") except IOError, exc: # exactly IOError, not LoadError self.assertEqual(exc.__class__, IOError) else: self.fail("expected IOError for invalid filename") # Invalid contents of cookies file (eg. bad magic string) # causes a LoadError.
Example #6
Source File: comcast.py From plugin.video.nbcsnliveextra-legacy with GNU General Public License v2.0 | 6 votes |
def GET_S_VI_COOKIE(self, referer): cj = cookielib.LWPCookieJar(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp')) cj.load(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp'),ignore_discard=True) ck = cookielib.Cookie(version=0, name='s_cc', value='true', port=None, port_specified=False, domain='.comcast.net', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False) cj.set_cookie(ck) ck = cookielib.Cookie(version=0, name='s_sq', value='%5B%5BB%5D%5D', port=None, port_specified=False, domain='.comcast.net', domain_specified=False, domain_initial_dot=False, path='/', path_specified=True, secure=False, expires=None, discard=True, comment=None, comment_url=None, rest={'HttpOnly': None}, rfc2109=False) cj.set_cookie(ck) url = "https://serviceos.comcast.net/b/ss/comcastnet/1/H.27.5/s41303345554477?AQB=1&pccr=true&vidn=2C0299A205011584-60000137E007532F&&ndh=1&t=17%2F9%2F2016%2016%3A23%3A32%201%20240&fid=1F8FC523BD7D4396-2E7FF98D1A765CCC&ce=UTF-8&ns=comcast&pageName=mobile%20app%20sign%20in&g=https%3A%2F%2Flogin.comcast.net%2Flogin%3Fr%3Dcomcast.net%26s%3Doauth%26continue%3Dhttps%253A%252F%252Flogin.comcast.net%252Foauth%252Fauthorize%253Fresponse_type%253Dcode%2526redirect_uri%253Dhttps%253A%252F%252Fsp.auth.adobe.com%252Fadobe-services%252Foauth2%2526state%253DQyqYoV%2526scope%253Dopenid%252520prof&cc=USD&ch=sign%20in&events=event11&c1=%2Flogin%2F%3Amobile%20app%20sign%20in&v1=%2Flogin%2F%3Amobile%20app%20sign%20in&c4=sign%20in&c7=adobepass-nbcsports&v7=adobepass-nbcsports&c23=small&c31=comcast&v31=mobile%20app%20sign%20in&c32=cim&v32=cim&c33=comcast%20net&v33=comcast%20net&c34=comcast%20net%3Asign%20in&c35=authentication&v35=authentication&c36=site%3Ahome&v36=site%3Ahome&v41=small&c44=anonymous%3Amobile%20app%20sign%20in&v47=anonymous&h1=comcast%3Acim%3Acomcast%20net%3Asign%20in%3Amobile%20app%20sign%20in&h2=%2Flogin&s=375x667&c=32&j=1.6&v=N&k=Y&bw=375&bh=667&-g=ile%252520https%253A%252F%252Flogin.comcast.net%252Fpdp%252Ftve%2526client_id%253Dadobepass-nbcsports%2526acr_values%253Durn%253Aoasis%253Anames%253Atc%253ASAML%253A2.0%253Aac%253Aclasses%253AInternetProtocol%2526response%253D1%26reqId%3D51e0dfcb-71e4-4a3f-96ad-8b8366155e6b%26ipAddrAuthn%3D1%26client_id%3Dadobepass-nbcsports&AQE=1" opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [ ("Accept", "*/*"), ("Accept-Encoding", "gzip, deflate"), ("Accept-Language", "en-us"), ("Connection", "keep-alive"), ("Referer", referer), ("User-Agent", UA_IPHONE)] resp = opener.open(url) resp.close() SAVE_COOKIE(cj)
Example #7
Source File: utils.py From WeixinBot with Apache License 2.0 | 6 votes |
def set_cookie(cookie_file): """ @brief Load cookie from file @param cookie_file @param user_agent @return cookie, LWPCookieJar """ cookie = cookielib.LWPCookieJar(cookie_file) try: cookie.load(ignore_discard=True) except: Log.error(traceback.format_exc()) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie)) opener.addheaders = Constant.HTTP_HEADER_USERAGENT urllib2.install_opener(opener) return cookie
Example #8
Source File: test_cookielib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_bad_magic(self): from cookielib import LWPCookieJar, MozillaCookieJar, LoadError # IOErrors (eg. file doesn't exist) are allowed to propagate filename = test_support.TESTFN for cookiejar_class in LWPCookieJar, MozillaCookieJar: c = cookiejar_class() try: c.load(filename="for this test to work, a file with this " "filename should not exist") except IOError, exc: # exactly IOError, not LoadError self.assertEqual(exc.__class__, IOError) else: self.fail("expected IOError for invalid filename") # Invalid contents of cookies file (eg. bad magic string) # causes a LoadError.
Example #9
Source File: default.py From ru with GNU General Public License v2.0 | 6 votes |
def GET(url, referer, post_params=None): headers['Referer'] = referer if post_params is not None: post_params = urllib.urlencode(post_params) headers['Content-Type'] = 'application/x-www-form-urlencoded' elif headers.has_key('Content-Type'): del headers['Content-Type'] jar = cookielib.LWPCookieJar(cookiepath) if os.path.isfile(cookiepath): jar.load() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar)) urllib2.install_opener(opener) req = urllib2.Request(url, post_params, headers) response = opener.open(req) the_page = response.read() response.close() jar.save() return the_page
Example #10
Source File: default.py From ru with GNU General Public License v2.0 | 6 votes |
def GET(url, referer, post_params=None): headers['Referer'] = referer url = get_full_url(url) if post_params is not None: post_params = urllib.urlencode(post_params) headers['Content-Type'] = 'application/x-www-form-urlencoded' elif headers.has_key('Content-Type'): del headers['Content-Type'] jar = cookielib.LWPCookieJar(cookiepath) if xbmcvfs.exists(cookiepath): jar.load() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar)) urllib2.install_opener(opener) req = urllib2.Request(url, post_params, headers) response = opener.open(req) the_page = response.read() response.close() jar.save() return the_page
Example #11
Source File: sport365.py From bugatsinho.github.io with GNU General Public License v3.0 | 6 votes |
def getUrlrh(url, data=None, header={}, usecookies=True): cj = cookielib.LWPCookieJar() if usecookies: opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) if not header: header = {'User-Agent':UA} rh={} req = urllib2.Request(url, data, headers=header) try: response = urllib2.urlopen(req, timeout=15) for k in response.headers.keys(): rh[k]=response.headers[k] link = response.read() response.close() except: link='' c = ''.join(['%s=%s' % (c.name, c.value) for c in cj]) if cj else '' return link,rh
Example #12
Source File: video.py From xbmc-addons-chinese with GNU General Public License v2.0 | 6 votes |
def getBrowers(): br = mechanize.Browser(history=NoHistory()) #options br.set_handle_equiv(True) #br.set_handle_gzip(True) br.set_handle_redirect(True) br.set_handle_referer(True) br.set_handle_robots(False) cj = cookielib.LWPCookieJar() br.set_cookiejar(cj)##关联cookies br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) br.set_debug_http(False) br.set_debug_redirects(False) br.set_debug_responses(False) br.addheaders = [("User-agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36")] return br
Example #13
Source File: httpclient.py From ru with GNU General Public License v2.0 | 6 votes |
def GET(self, url, referer, post_params=None): headers['Referer'] = referer url = self.get_full_url(url) if post_params is not None: post_params = urllib.urlencode(post_params) headers['Content-Type'] = 'application/x-www-form-urlencoded' elif headers.has_key('Content-Type'): del headers['Content-Type'] jar = cookielib.LWPCookieJar(self.cookie_path) if xbmcvfs.exists(self.cookie_path): jar.load() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar)) urllib2.install_opener(opener) req = urllib2.Request(url, post_params, headers) response = opener.open(req) the_page = response.read() response.close() jar.save() return the_page
Example #14
Source File: proxy.py From plugin.video.ustvvod with GNU General Public License v2.0 | 6 votes |
def serveFile(self, fURL, sendData, httphandler = None, cookienum = 0): cj = cookielib.LWPCookieJar(ustvpaths.COOKIE % str(cookienum)) if httphandler is None: opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) else: opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), httphandler) request = urllib2.Request(url = fURL) sheaders = self.decodeHeaderString(self.headers.headers) del sheaders['Host'] sheaders['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0' for key in sheaders: opener.addheaders = [(key, sheaders[key])] if os.path.isfile(ustvpaths.COOKIE % str(cookienum)): cj.load(ignore_discard = True) cj.add_cookie_header(request) response = opener.open(request, timeout = TIMEOUT) self.send_response(200) headers = response.info() for key in headers: try: self.send_header(key, headers[key]) except Exception, e: print "Exception: ", e pass
Example #15
Source File: form_with_cookie.py From cmdbac with Apache License 2.0 | 5 votes |
def __init__(self, *args, **kwargs): super(FormWithCookieSpider, self).__init__(*args, **kwargs) self.start_urls = [kwargs.get('start_url')] self.cookiejar = cookielib.LWPCookieJar() self.cookiejar.load(kwargs.get('cookie_jar')) self.rules = ( Rule (SgmlLinkExtractor(allow=('')), callback='parse_form', follow=True, process_request='add_cookie_for_request'), ) super(FormWithCookieSpider, self)._compile_rules()
Example #16
Source File: poc_cve-2014-2022.py From pub with GNU General Public License v2.0 | 5 votes |
def __init__(self,baseurl,params, debuglevel=1): self.cookies = cookielib.LWPCookieJar() handlers = [ urllib2.HTTPHandler(debuglevel=debuglevel), urllib2.HTTPSHandler(debuglevel=debuglevel), urllib2.HTTPCookieProcessor(self.cookies) ] self.browser = urllib2.build_opener(*handlers) self.baseurl=baseurl self.params = params
Example #17
Source File: rest_Utils.py From warriorframework with Apache License 2.0 | 5 votes |
def resolve_value_of_cookies(element): """ This function evaluates user input for cookies. If a file path is given, then a cookiejar object is created and the contents of the file are loaded into the object. This object is then returned. Else, a dictionary would be created out of the string given input = "foo=foo1; bar=bar1; ; =foobar; barfoo=" return value = {'foo': 'foo1', 'bar': 'bar1'} If the dictionary is empty at the end of the function, None is retuened. """ if element is not None and element is not False and element != "": abs_path = file_Utils.getAbsPath(element, sys.path[0]) if os.path.exists(abs_path): element = cookielib.LWPCookieJar(element) try: element.load() except cookielib.LoadError: pNote("Cookies could not be loaded from {}.".format(element), "error") element = None except Exception as e: pNote("An Error Occurred: {0}".format(e), "error") else: element = convert_string_to_dict(element) else: element = None return element
Example #18
Source File: coursera_offline.py From coursera-offline with GNU General Public License v3.0 | 5 votes |
def login(email, password): # Logs into coursera and sets the cookie # Spoofs the requests to Coursera servers to login # Returns the cookie jar cookie_jar = cookielib.LWPCookieJar(absolute_path(COOKIE_FILE)) if has_cookiefile(): cookie_jar.load(ignore_discard=True) if isLoggedIn(cookie_jar): return cookie_jar elif not email or not password: exit_with_message('Provide email and password') opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie_jar)) csrf2_token = 'csrf2_token_' + csrfMake(8) csrf2_token_value = csrfMake() csrf_token = csrfMake() csrf2 = get_cookie(csrf2_token, csrf2_token_value) csrf = get_cookie('csrftoken', csrf_token) cookie_jar.set_cookie(csrf) cookie_jar.set_cookie(csrf2) DEFAULT_HEADERS['X-CSRFToken'] = csrf_token DEFAULT_HEADERS['X-CSRF2-Token'] = csrf2_token_value DEFAULT_HEADERS['X-CSRF2-Cookie'] = csrf2_token data = { 'email' : email, 'password' : password, 'webrequest' : 'true' } try: login_res = opener.open(urllib2.Request(AUTH_URL, urllib.urlencode(data), DEFAULT_HEADERS)) except Exception, e: exit_with_message(e)
Example #19
Source File: bright_house.py From plugin.video.nbcsnliveextra-legacy with GNU General Public License v2.0 | 5 votes |
def GET_IDP(self): if not os.path.exists(ADDON_PATH_PROFILE): os.makedirs(ADDON_PATH_PROFILE) cj = cookielib.LWPCookieJar(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp')) #IDP_URL= 'https://sp.auth.adobe.com/adobe-services/authenticate?requestor_id=nbcsports&redirect_url=http://stream.nbcsports.com/nbcsn/index_nbcsn-generic.html?referrer=http://stream.nbcsports.com/liveextra/&domain_name=stream.nbcsports.com&mso_id=TWC&noflash=true&no_iframe=true' opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [ ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), ("Accept-Language", "en-us"), ("Proxy-Connection", "keep-alive"), ("Connection", "keep-alive"), ("User-Agent", UA_IPHONE)] resp = opener.open(IDP_URL) idp_source = resp.read() resp.close() #print idp_source #cj.save(ignore_discard=True); SAVE_COOKIE(cj) idp_source = idp_source.replace('\n',"") saml_request = FIND(idp_source,'<input type="hidden" name="SAMLRequest" value="','"') #print saml_request relay_state = FIND(idp_source,'<input type="hidden" name="RelayState" value="','"') saml_submit_url = FIND(idp_source,'action="','"') print saml_submit_url #print relay_state return saml_request, relay_state, saml_submit_url
Example #20
Source File: submit.py From cmdbac with Apache License 2.0 | 5 votes |
def submit_form(form, inputs, br = None): if br == None: br = mechanize.Browser() cj = cookielib.LWPCookieJar() br.set_cookiejar(cj) br.set_handle_robots(False) br.open(form['url'].encode("ascii","ignore")) br.select_form(nr=get_form_index(br, form)) for input in form['inputs']: if input['name'] in inputs: try: if br.find_control(name = input['name'], type = input['type']) == None: continue if input['type'] == 'file': filename = inputs[input['name']]['filename'] upload_filename = os.path.basename(filename) mime_type = inputs[input['name']]['mime_type'] br.form.add_file(open(filename), mime_type, upload_filename, name = input['name']) br.form.set_all_readonly(False) elif input['type'] == 'checkbox': br.find_control(name = input['name'], type = input['type']).selected = inputs[input['name']] else: if br.find_control(name = input['name'], type = input['type']).readonly: continue if input['type'] == 'radio': continue br[input['name']] = inputs[input['name']] except: # traceback.print_exc() pass response = br.submit().code return response, br
Example #21
Source File: optimum.py From plugin.video.nbcsnliveextra-legacy with GNU General Public License v2.0 | 5 votes |
def GET_IDP(self): if not os.path.exists(ADDON_PATH_PROFILE): os.makedirs(ADDON_PATH_PROFILE) cj = cookielib.LWPCookieJar(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp')) #IDP_URL= 'https://sp.auth.adobe.com/adobe-services/authenticate?requestor_id=nbcsports&redirect_url=http://stream.nbcsports.com/nbcsn/index_nbcsn-generic.html?referrer=http://stream.nbcsports.com/liveextra/&domain_name=stream.nbcsports.com&mso_id=TWC&noflash=true&no_iframe=true' opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [ ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), ("Accept-Language", "en-us"), ("Proxy-Connection", "keep-alive"), ("Connection", "keep-alive"), ("User-Agent", UA_IPHONE)] resp = opener.open(IDP_URL) idp_source = resp.read() resp.close() #print idp_source #cj.save(ignore_discard=True); SAVE_COOKIE(cj) idp_source = idp_source.replace('\n',"") saml_request = FIND(idp_source,'<input type="hidden" name="SAMLRequest" value="','"') #print saml_request relay_state = FIND(idp_source,'<input type="hidden" name="RelayState" value="','"') saml_submit_url = FIND(idp_source,'action="','"') print saml_submit_url #print relay_state return saml_request, relay_state, saml_submit_url
Example #22
Source File: scrape.py From Spectre with MIT License | 5 votes |
def no_js_get_source(self): br = Browser() br.set_handle_equiv(True) br.set_handle_referer(True) br.set_handle_robots(False) br.set_cookiejar(LWPCookieJar()) br.addheaders=[('User-agent', USER_AGENT)] br.set_handle_refresh(_http.HTTPRefreshProcessor(), max_time=10) try:return br.open(self.url).read() except:exit('[!] Failed to fetch html source')
Example #23
Source File: poc_cve-2014-2021.py From pub with GNU General Public License v2.0 | 5 votes |
def __init__(self,baseurl,params, debuglevel=1): self.cookies = cookielib.LWPCookieJar() handlers = [ urllib2.HTTPHandler(debuglevel=debuglevel), urllib2.HTTPSHandler(debuglevel=debuglevel), urllib2.HTTPCookieProcessor(self.cookies) ] self.browser = urllib2.build_opener(*handlers) self.baseurl=baseurl self.params = params
Example #24
Source File: dish.py From plugin.video.nbcsnliveextra-legacy with GNU General Public License v2.0 | 5 votes |
def FIRST_BOOKEND(self,first_bookend_url): cj = cookielib.LWPCookieJar() cj.load(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp'),ignore_discard=True) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [ ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), ("Accept-Encoding", "gzip, deflate"), ("Accept-Language", "en-us"), ("Content-Type", "application/x-www-form-urlencoded"), ("Proxy-Connection", "keep-alive"), ("Connection", "keep-alive"), ("Origin", "https://identity1.dishnetwork.com"), ("Referer", first_bookend_url), ("User-Agent", UA_IPHONE)] resp = opener.open(first_bookend_url) idp_source = resp.read() print resp.geturl() print resp.info() #print resp.getcode() resp.close() #print idp_source #cj.save(ignore_discard=True); cj.save(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp'),ignore_discard=True); social_login_url = resp.geturl() return social_login_url
Example #25
Source File: dish.py From plugin.video.nbcsnliveextra-legacy with GNU General Public License v2.0 | 5 votes |
def POST_SAML_REQUEST(self, saml_request, relay_state, saml_submit_url): ################################################################### #Post username and password to idp ################################################################### #cj = cookielib.LWPCookieJar(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp')) cj = cookielib.LWPCookieJar() cj.load(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp'),ignore_discard=True) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [ ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), ("Accept-Encoding", "gzip, deflate"), ("Accept-Language", "en-us"), ("Content-Type", "application/x-www-form-urlencoded"), ("Proxy-Connection", "keep-alive"), #("Connection", "keep-alive"), ("Origin", "https://sp.auth.adobe.com"), ("Referer", IDP_URL), ("User-Agent", UA_IPHONE)] login_data = urllib.urlencode({'SAMLRequest' : saml_request, 'RelayState' : relay_state, }) resp = opener.open(saml_submit_url, login_data) idp_source = resp.read() #print resp.geturl() #print resp.info() #print resp.getcode() resp.close() cj.save(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp'),ignore_discard=True); first_bookend_url = resp.geturl()+ "&history=1" return first_bookend_url #print idp_source
Example #26
Source File: dish.py From plugin.video.nbcsnliveextra-legacy with GNU General Public License v2.0 | 5 votes |
def GET_IDP(self): if not os.path.exists(ADDON_PATH_PROFILE): os.makedirs(ADDON_PATH_PROFILE) cj = cookielib.LWPCookieJar(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp')) #IDP_URL= 'https://sp.auth.adobe.com/adobe-services/authenticate?requestor_id=nbcsports&redirect_url=http://stream.nbcsports.com/nbcsn/index_nbcsn-generic.html?referrer=http://stream.nbcsports.com/liveextra/&domain_name=stream.nbcsports.com&mso_id=TWC&noflash=true&no_iframe=true' opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [ ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), ("Accept-Language", "en-us"), ("Proxy-Connection", "keep-alive"), ("Connection", "keep-alive"), ("User-Agent", UA_IPHONE)] resp = opener.open(IDP_URL) idp_source = resp.read() resp.close() #print idp_source SAVE_COOKIE(cj) idp_source = idp_source.replace('\n',"") saml_request = FIND(idp_source,'<input type="hidden" name="SAMLRequest" value="','"') #print saml_request relay_state = FIND(idp_source,'<input type="hidden" name="RelayState" value="','"') saml_submit_url = FIND(idp_source,'action="','"') print saml_submit_url #print relay_state return saml_request, relay_state, saml_submit_url
Example #27
Source File: recipe-501148.py From code with MIT License | 5 votes |
def send_cookie_auth(self, connection): """Include Cookie Authentication data in a header""" cj = cookielib.LWPCookieJar() cj.load(self.cookiefile) for cookie in cj: if cookie.name == 'UUID': uuidstr = cookie.value connection.putheader(cookie.name, cookie.value) ## override the send_host hook to also send authentication info
Example #28
Source File: sosac.py From plugin.video.sosac.ph with GNU General Public License v2.0 | 5 votes |
def __init__(self, username=None, password=None, filter=None, reverse_eps=False, force_czech=False, order_recently_by=0): ContentProvider.__init__(self, name='sosac.ph', base_url=MOVIES_BASE_URL, username=username, password=password, filter=filter) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.LWPCookieJar())) urllib2.install_opener(opener) self.reverse_eps = reverse_eps self.force_czech = force_czech self.streamujtv_user = None self.streamujtv_pass = None self.streamujtv_location = None self.order_recently_by = order_recently_by
Example #29
Source File: frontier.py From plugin.video.nbcsnliveextra-legacy with GNU General Public License v2.0 | 5 votes |
def GET_IDP(self): if not os.path.exists(ADDON_PATH_PROFILE): os.makedirs(ADDON_PATH_PROFILE) cj = cookielib.LWPCookieJar(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp')) #IDP_URL= 'https://sp.auth.adobe.com/adobe-services/authenticate?requestor_id=nbcsports&redirect_url=http://stream.nbcsports.com/nbcsn/index_nbcsn-generic.html?referrer=http://stream.nbcsports.com/liveextra/&domain_name=stream.nbcsports.com&mso_id=TWC&noflash=true&no_iframe=true' opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [ ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), ("Accept-Language", "en-us"), ("Proxy-Connection", "keep-alive"), ("Connection", "keep-alive"), ("User-Agent", UA_IPHONE)] resp = opener.open(IDP_URL) idp_source = resp.read() resp.close() #print idp_source #cj.save(ignore_discard=True); SAVE_COOKIE(cj) idp_source = idp_source.replace('\n',"") saml_request = FIND(idp_source,'<input type="hidden" name="SAMLRequest" value="','"') #print saml_request relay_state = FIND(idp_source,'<input type="hidden" name="RelayState" value="','"') saml_submit_url = FIND(idp_source,'action="','"') print saml_submit_url #print relay_state return saml_request, relay_state, saml_submit_url
Example #30
Source File: charter.py From plugin.video.nbcsnliveextra-legacy with GNU General Public License v2.0 | 5 votes |
def GET_IDP(self): if not os.path.exists(ADDON_PATH_PROFILE): os.makedirs(ADDON_PATH_PROFILE) cj = cookielib.LWPCookieJar(os.path.join(ADDON_PATH_PROFILE, 'cookies.lwp')) #IDP_URL= 'https://sp.auth.adobe.com/adobe-services/authenticate?requestor_id=nbcsports&redirect_url=http://stream.nbcsports.com/nbcsn/index_nbcsn-generic.html?referrer=http://stream.nbcsports.com/liveextra/&domain_name=stream.nbcsports.com&mso_id=TWC&noflash=true&no_iframe=true' opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) opener.addheaders = [ ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), ("Accept-Language", "en-us"), ("Proxy-Connection", "keep-alive"), ("Connection", "keep-alive"), ("User-Agent", UA_IPHONE)] resp = opener.open(IDP_URL) idp_source = resp.read() resp.close() #print idp_source #cj.save(ignore_discard=True); SAVE_COOKIE(cj) idp_source = idp_source.replace('\n',"") saml_request = FIND(idp_source,'<input type="hidden" name="SAMLRequest" value="','"') #print saml_request relay_state = FIND(idp_source,'<input type="hidden" name="RelayState" value="','"') saml_submit_url = FIND(idp_source,'action="','"') print saml_submit_url #print relay_state return saml_request, relay_state, saml_submit_url