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


Python Session.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import __init__ [as 别名]
	def __init__(self):
		Session.__init__(self)
		self.headers = {
			"User-Agent": "Oruga Amarilla transmit API",
			"Content-type": "application/x-www-form-urlencoded",
			"Accept": "text/plain"
			}
		with myfile.db('config.mod',':') as p:
			for k in p:
				if k[0]=='base':
					self.myID = k[1]
					debug.out2('This site name',self.myID)
				elif k[0]=='remote':
					self.server = k[1]
					debug.out2('Sending to server',self.server)
				elif k[0]=='header':
					self.headers[k[1]] = k[2]
					debug.out2('Adding POST header','{}:{}'.format(k[1],k[2]))
				elif k[0] in {'interval','pause'}:
					self.interval = int(k[1])
					debug.out2('Interval set to',self.interval)
				elif k[0] in {'iters','repeat'}:
					i = int(k[1])
					self.repeat = int(i)
					if not i: i = 'infinity'
					debug.out2('Setting iterations to',i)
		self.auth = (self.myID,self.passwd)
开发者ID:chlewey,项目名称:datatransmit,代码行数:29,代码来源:connect.py

示例2: __init__

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import __init__ [as 别名]
    def __init__(self, *args, **kwargs):
        Session.__init__(self, *args, **kwargs)

        self.timeout = 20.0

        if TIMEOUT_ADAPTER_NEEDED:
            self.mount("http://", HTTPAdapterWithReadTimeout())
            self.mount("https://", HTTPAdapterWithReadTimeout())
开发者ID:3cky,项目名称:livestreamer,代码行数:10,代码来源:http_session.py

示例3: __init__

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import __init__ [as 别名]
 def __init__(self, options, *args, **kwargs):
     Session.__init__(self, *args, **kwargs)
     adapter = HTTPAdapter(max_retries=retry)
     self.mount('http://', adapter)
     self.mount('https://', adapter)
     self.verify = options.ssl_verify
     self.proxy = options.proxy
     if options.http_headers:
         self.headers.update(self.split_header(options.http_headers))
     self.headers.update({"User-Agent": FIREFOX_UA})
开发者ID:olof,项目名称:svtplay-dl,代码行数:12,代码来源:__init__.py

示例4: __init__

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import __init__ [as 别名]
    def __init__(self, config=dict(), *args, **kwargs):
        Session.__init__(self, *args, **kwargs)
        adapter = HTTPAdapter(max_retries=retry)

        self.mount('http://', adapter)
        self.mount('https://', adapter)
        self.verify = config.get("ssl_verify")
        self.proxy = config.get("proxy")
        if config.get("http_headers"):
            self.headers.update(self.split_header(config.get("http_headers")))
        self.headers.update({"User-Agent": FIREFOX_UA})
开发者ID:olof,项目名称:debian-svtplay-dl,代码行数:13,代码来源:http.py

示例5: __init__

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import __init__ [as 别名]
    def __init__(self, pool=None,  minthreads=1, maxthreads=4, **kwargs):
        """Creates a twisted aware Session

        Notes
        ~~~~~

        * If you provide both `pool` and `max_workers`, the latter is
          ignored and provided threadpool is used as is.
        """
        requestsSession.__init__(self, **kwargs)
        if pool is None:
            pool = ThreadPool(minthreads=minthreads, maxthreads=maxthreads)
        self.pool = pool
        pool.start()
开发者ID:djmitche,项目名称:txrequests,代码行数:16,代码来源:sessions.py

示例6: __init__

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import __init__ [as 别名]
    def __init__(self, pool=None,  minthreads=1, maxthreads=4, **kwargs):
        """Creates a twisted aware Session

        Notes
        ~~~~~

        * If you provide both `pool` and `max_workers`, the latter is
          ignored and provided threadpool is used as is.
        """
        requestsSession.__init__(self, **kwargs)
        self.ownPool = False
        if pool is None:
            self.ownPool = True
            pool = ThreadPool(minthreads=minthreads, maxthreads=maxthreads)
            # unclosed ThreadPool leads to reactor hangs at shutdown
            # this is a problem in many situation, so better enforce pool stop here
            reactor.addSystemEventTrigger("before", "shutdown", lambda:pool.stop())
        self.pool = pool
        if self.ownPool:
            pool.start()
开发者ID:jdemaeyer,项目名称:txrequests,代码行数:22,代码来源:sessions.py

示例7: __init__

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import __init__ [as 别名]
 def __init__(self, options, *args, **kwargs):
     Session.__init__(self, *args, **kwargs)
     self.verify = options.ssl_verify
     if options.http_headers:
         self.headers.update(self.split_header(options.http_headers))
     self.headers.update({"User-Agent": FIREFOX_UA})
开发者ID:chenliang100,项目名称:svtplay-dl,代码行数:8,代码来源:__init__.py

示例8: __init__

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import __init__ [as 别名]
 def __init__(self, *args, **kwargs):
     Session.__init__(self, *args, **kwargs)
     self.referer = None
开发者ID:cyanut,项目名称:iqiyi-downloader,代码行数:5,代码来源:dl.py

示例9: __init__

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import __init__ [as 别名]
 def __init__(self, *args, **kwargs):
     Session.__init__(self, *args, **kwargs)
开发者ID:Fredro,项目名称:svtplay-dl,代码行数:4,代码来源:__init__.py


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