本文整理汇总了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))
示例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()
示例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
示例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
示例5: __setstate__
# 需要导入模块: import http [as 别名]
# 或者: from http import cookiejar [as 别名]
def __setstate__(self, state):
self.__dict__=state
self.__shared={}
self.__global={}
self.cookiejar = CookieStore()
示例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)
示例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()
示例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()
示例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
示例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
示例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, {})
示例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()
示例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()
示例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)
示例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