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


Python http.cookiejar方法代码示例

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


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

示例1: oscrc_create

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def oscrc_create(self, oscrc_file, apiurl, cookiejar_file, user):
        sentry_dsn = sentry_client().dsn
        sentry_environment = sentry_client().options.get('environment')

        oscrc_file.write('\n'.join([
            '[general]',
            # Passthru sentry_sdk options to allow for reporting on subcommands.
            'sentry_sdk.dsn = {}'.format(sentry_dsn) if sentry_dsn else '',
            'sentry_sdk.environment = {}'.format(sentry_environment) if sentry_environment else '',
            'apiurl = {}'.format(apiurl),
            'cookiejar = {}'.format(cookiejar_file.name),
            'staging.color = 0',
            '[{}]'.format(apiurl),
            'user = {}'.format(user),
            'pass = invalid',
            '',
        ]).encode('utf-8'))
        oscrc_file.flush()

        # In order to avoid osc clearing the cookie file the modified time of
        # the oscrc file must be set further into the past.
        # if int(round(config_mtime)) > int(os.stat(cookie_file).st_mtime):
        recent_past = time.time() - 3600
        os.utime(oscrc_file.name, (recent_past, recent_past)) 
开发者ID:openSUSE,项目名称:openSUSE-release-tools,代码行数:26,代码来源:obs_operator.py

示例2: __init__

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def __init__(self,d=None):
        if not d: d={}

        if isinstance(d,str):
            d=ustr(d)
            try:
                d=yaml.load(d, Loader=yaml.FullLoader)
            except Exception as e:
                raise RMFormatException("Env conf is not yaml")

        if type(d) not in [dict,Env]:
            # raise RMFormatException("Env conf is not a dict %s" % str(d))
            d={}

        self.__shared={} # shared saved scope between all cloned Env
        self.__global={} # shared global saved scope between all cloned Env (from BEGIN only)

        dict.__init__(self,dict(d))
        self.cookiejar = CookieStore() 
开发者ID:manatlan,项目名称:reqman,代码行数:21,代码来源:reqman.py

示例3: load

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def load(self):
        con = sqlite3.connect(self.tmp_cookie_file)
        cur = con.cursor()
        cur.execute('select host, path, isSecure, expiry, name, value from moz_cookies '
                    'where host like "%{}%"'.format(self.domain_name))

        cj = http.cookiejar.CookieJar()
        for item in cur.fetchall():
            c = create_cookie(*item)
            cj.set_cookie(c)
        con.close()

        self.__add_session_cookies(cj)
        self.__add_session_cookies_lz4(cj)

        return cj 
开发者ID:borisbabic,项目名称:browser_cookie3,代码行数:18,代码来源:__init__.py

示例4: clone

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def clone(self,cloneSharedScope=True):
        newOne=Env({})
        dict_merge(newOne,self)
        newOne.cookiejar= CookieStore( self.cookiejar.export() )

        dict_merge(newOne,self.__global) # declare those of the global scope !!! (from BEGIN only)
        newOne.__global = self.__global  #mk a ref to global

        if cloneSharedScope: #used (at false) at each Reqs() constructor (to start on a sane base)
            dict_merge(newOne,self.__shared) # declare those of the shared scope !!!
            newOne.__shared = self.__shared  #mk a ref to shared
        return newOne 
开发者ID:manatlan,项目名称:reqman,代码行数:14,代码来源:reqman.py

示例5: __setstate__

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def __setstate__(self, state):
        self.__dict__=state
        self.__shared={}
        self.__global={}
        self.cookiejar = CookieStore() 
开发者ID:manatlan,项目名称:reqman,代码行数:7,代码来源:reqman.py

示例6: __init__

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def __init__(self, db, session, policy=None):
		http.cookiejar.CookieJar.__init__(self, policy)

		self.log = logging.getLogger("Main.DbCookieJar")

		self.headers = None
		self.db      = db

		self.exit_saved = False
		atexit.register(self._save_at_exit) 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:12,代码来源:DbCookieJar.py

示例7: __load_cookies

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def __load_cookies(self, sess):

		have = sess.query(db.WebCookieDb)                                           \
			.filter(db.WebCookieDb.ua_user_agent        == self.headers['User-Agent'])      \
			.filter(db.WebCookieDb.ua_accept_language   == self.headers['Accept-Language']) \
			.filter(db.WebCookieDb.ua_accept            == self.headers['Accept'])          \
			.filter(db.WebCookieDb.ua_accept_encoding   == self.headers['Accept-Encoding']) \
			.all()

		for cookie in have:
			new_ck = http.cookiejar.Cookie(
				version            = cookie.c_version,
				name               = cookie.c_name,
				value              = cookie.c_value,
				port               = cookie.c_port,
				port_specified     = cookie.c_port_specified,
				domain             = cookie.c_domain,
				domain_specified   = cookie.c_domain_specified,
				domain_initial_dot = cookie.c_domain_initial_dot,
				path               = cookie.c_path,
				path_specified     = cookie.c_path_specified,
				secure             = cookie.c_secure,
				expires            = cookie.c_expires,
				discard            = cookie.c_discard,
				comment            = cookie.c_comment,
				comment_url        = cookie.c_comment_url,
				rest               = json.loads(cookie.c_rest),
				rfc2109            = cookie.c_rfc2109,
				)
			self.set_cookie(new_ck)

		self.log.info("Loaded %s cookies from db.", len(have))

		sess.commit() 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:36,代码来源:DbCookieJar.py

示例8: sync_cookies

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def sync_cookies(self):
		assert self.headers != None
		with self.db.session_context("cookiejar") as sess:
			self.__save_cookies(sess)
			self.__load_cookies(sess)
			sess.commit() 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:8,代码来源:DbCookieJar.py

示例9: save

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def save(self, filename=None, ignore_discard=False, ignore_expires=False):
		if self.exit_saved:
			return

		assert self.headers != None
		for _ in range(10):
			try:
				with self.db.session_context("cookiejar") as sess:
					self.__save_cookies(sess)
					sess.commit()
				return
			except sqlalchemy.exc.SQLAlchemyError:
				pass 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:15,代码来源:DbCookieJar.py

示例10: load

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def load(self, filename=None, ignore_discard=False, ignore_expires=False):
		if self.exit_saved:
			return

		assert self.headers != None
		for _ in range(10):
			try:
				with self.db.session_context("cookiejar") as sess:
					self.__load_cookies(sess)
					sess.commit()
				return
			except sqlalchemy.exc.SQLAlchemyError:
				pass 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:15,代码来源:DbCookieJar.py

示例11: create_cookie

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def create_cookie(host, path, secure, expires, name, value):
    """Shortcut function to create a cookie
    """
    return http.cookiejar.Cookie(0, name, value, None, False, host, host.startswith('.'), host.startswith('.'), path,
                                 True, secure, expires, False, None, None, {}) 
开发者ID:borisbabic,项目名称:browser_cookie3,代码行数:7,代码来源:__init__.py

示例12: chrome

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def chrome(cookie_file=None, domain_name=""):
    """Returns a cookiejar of the cookies used by Chrome. Optionally pass in a
    domain name to only load cookies from the specified domain
    """
    return Chrome(cookie_file, domain_name).load() 
开发者ID:borisbabic,项目名称:browser_cookie3,代码行数:7,代码来源:__init__.py

示例13: firefox

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def firefox(cookie_file=None, domain_name=""):
    """Returns a cookiejar of the cookies and sessions used by Firefox. Optionally
    pass in a domain name to only load cookies from the specified domain
    """
    return Firefox(cookie_file, domain_name).load() 
开发者ID:borisbabic,项目名称:browser_cookie3,代码行数:7,代码来源:__init__.py

示例14: test_other_http_imports

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def test_other_http_imports(self):
        import http
        import http.server
        import http.cookies
        import http.cookiejar
        self.assertTrue(True) 
开发者ID:hughperkins,项目名称:kgsgo-dataset-preprocessor,代码行数:8,代码来源:test_standard_library.py

示例15: __init__

# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def __init__(self, cookiejar=None):
        import http.cookiejar
        if cookiejar is None:
            cookiejar = http.cookiejar.CookieJar()
        self.cookiejar = cookiejar 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:request.py


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