• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python client.HTTPClientFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.web.client.HTTPClientFactory的典型用法代码示例。如果您正苦于以下问题:Python HTTPClientFactory类的具体用法?Python HTTPClientFactory怎么用?Python HTTPClientFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: __init__

	def __init__(self, temp_token, log):
		self.temp_token = temp_token
		self.log = log
		self.url = "https://www.google.com/accounts/AuthSubSessionToken"
		"""
		self.keyfile = aztk_config.services.get('servers.httpserver', "google_ssl_priv_key")
		self.log.debug("keyfile: [%s]" % self.keyfile)
		self.passphrase = aztk_config.services.get('servers.httpserver', "google_ssl_priv_passphrase")
		self.time_stamp = int(time.time())
		self.rand_num = str(getrandbits(64))
		self.data = "GET %s %s %s" % (self.url, self.time_stamp, self.rand_num)
		"""
		#self.make_sig()
		header_dict = {
			'Accept': "*/*",
			#'Authorization': str("AuthSub token=\"%s\" data=\"%s\" sig=\"%s\" sigalg=\"rsa-sha1\"" % (self.temp_token, self.data, self.sig)),
			'Authorization': "AuthSub token=\"%s\"" % (self.temp_token),
			'Content-Type': "application/x-www-form-urlencoded"
		}
		self.log.debug("header_dict:\n%s" % pformat(header_dict))
		HTTPClientFactory.__init__(self, self.url, headers=header_dict, agent="Zoto/3.0.1")
		self.deferred.addCallback(self.handle_response)
		self.deferred.addErrback(self.handle_error)
		self.perm_token = ""
		self.expire_time = ""
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:25,代码来源:beta_blogger.py


示例2: getPage

def getPage(url, bindAddress = None, *arg, **kw):
    # reimplemented here to insert bindAddress

    # _parse() deprecated in twisted 13.1.0 in favor of the _URI class
    if hasattr(client, '_parse'):
        scheme, host, port, path = client._parse(url)
    else:
        # _URI class renamed to URI in 15.0.0
        try:
            from twisted.web.client import _URI as URI
        except ImportError:
            from twisted.web.client import URI
        
        uri = URI.fromBytes(url)
        scheme = uri.scheme
        host = uri.host
        port = uri.port
        path = uri.path

    factory = HTTPClientFactory(url, *arg, **kw)
    factory.noisy = False
	
    if scheme == 'https':
        from twisted.internet import ssl
        context = ssl.ClientContextFactory()
        reactor.connectSSL(host, port, factory, context, 
            bindAddress = bindAddress)
    else:
        reactor.connectTCP(host, port, factory, bindAddress = bindAddress)
    return factory.deferred
开发者ID:Architektor,项目名称:PySnip,代码行数:30,代码来源:web.py


示例3: __init__

	def __init__(self, url, contextFactory=None, retries=0):

		url = stripNoPrint(url)
		if retries > 0:
			print "Retrying: ", url
		else:
			print "Get: ", url
		self.retries = retries
		self.url = url
		self.charset = None
		scheme, host, port, path = _parse(url)
		HTTPClientFactory.__init__(self, url,
			method='GET', postdata=None, headers=None,
			agent='Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;' + 
				' rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10')
		if scheme == 'https':
			from twisted.internet import ssl
			if contextFactory is None:
				contextFactory = ssl.ClientContextFactory()
			reactor.connectSSL(host, port, self, contextFactory)
		else:
			reactor.connectTCP(host, port, self)
		
		self.deferred.addCallbacks(self.getCharset, self.Err)
		self.deferred.addCallbacks(self.getTitle, self.Err)
开发者ID:kunwon1,项目名称:Subtitle,代码行数:25,代码来源:TitleGetter2.py


示例4: __init__

    def __init__(self, url):
        HTTPClientFactory.__init__(self, url)
        self.deferred = defer.Deferred()
        self.waiting = 1

        self.on_page_part = Event()
        self.on_page_end = Event()
开发者ID:ceronman,项目名称:pixtream,代码行数:7,代码来源:streamclient.py


示例5: __init__

 def __init__(self, user, password, callback, stream_type='spritzer', agent='TwitterHooks', query_params=None):
     url = 'http://stream.twitter.com/%s.json' % stream_type
     if query_params:
         url = '%s?%s' % (url, urllib.urlencode(query_params))
     self.auth = base64.b64encode('%s:%s' % (user, password))
     self.callback = callback
     self.last_retry = 0
     HTTPClientFactory.__init__(self, url=url, agent=agent)
开发者ID:progrium,项目名称:twitterhooks,代码行数:8,代码来源:transformer.py


示例6: __init__

 def __init__(self, cacheDir, url, method='GET', postdata=None, headers={}, agent="Gazouilleur with Twisted ConditionalPageGetter", timeout=0, cookies=None, followRedirect=True, redirectLimit=5):
     self.cachefile = path.join(cacheDir, get_hash(url))
     self.last_modified = None
     if path.exists(self.cachefile):
         with open(self.cachefile) as cache:
             self.last_modified = cache.readline().strip()
             headers['If-Modified-Since'] = self.last_modified
     HTTPClientFactory.__init__(self, url, method=method, postdata=postdata, headers=headers, agent=agent, timeout=timeout, cookies=cookies, followRedirect=followRedirect, redirectLimit=redirectLimit)
开发者ID:Psycojoker,项目名称:gazouilleur,代码行数:8,代码来源:httpget.py


示例7: __init__

 def __init__(self, url, proxy_host, proxy_port, *args, **kwargs):
     """
     Strips out proxy_host and proxy_port, then passes the rest of the
     arguments to base class (HTTPClientFactory)
     """
     self.proxy_host = proxy_host
     self.proxy_port = proxy_port
     HTTPClientFactory.__init__(self, url, *args, **kwargs)
开发者ID:shawnchin,项目名称:goanna,代码行数:8,代码来源:webclient.py


示例8: __init__

 def __init__(self, **kwargs):
     self.reqs = kwargs.pop('requests')
     self.report = kwargs.pop('report')
     self.ip = kwargs.pop('ip')
     self.host_port = kwargs.pop('port')
     if 'auth' in kwargs:
         self.protocol.auth = kwargs.pop('auth')
     self.activecons = 0
     self.total_reqs = len(self.reqs)
     HTTPClientFactory.__init__(self, timeout=15, **kwargs)
开发者ID:jasonthomas,项目名称:logreplay,代码行数:10,代码来源:tworkers.py


示例9: __init__

    def __init__(self, *args, **kwds):
        HTTPClientFactory.__init__(self, *args, **kwds)

        if self.url in self.cache:
            if 'etag' in self.cache[self.url]:
                self.headers['etag'] = self.cache[self.url]['etag']
            elif 'last-modified' in self.cache[self.url]:
                self.headers['if-modified-since'] = self.cache[self.url]['last-modified']
            elif 'date' in self.cache[self.url]:
                self.headers['if-modified-since'] = self.cache[self.url]['date']
开发者ID:laudarch,项目名称:Tor2web,代码行数:10,代码来源:lists.py


示例10: __init__

	def __init__(self, frob, log):
		self.frob = frob
		self.log = log
		self.sig = md5.md5("%sapi_key%sfrob%smethodflickr.auth.getToken" % (SECRET, API_KEY, self.frob)).hexdigest()
		url = "http://api.flickr.com/services/rest/?method=flickr.auth.getToken&api_key=%s&frob=%s&api_sig=%s" % (API_KEY, self.frob, self.sig)
		self.log.debug("url: %s" % url)
		HTTPClientFactory.__init__(self, url, agent="Zoto/3.0.1")
		self.deferred.addCallback(self.handle_response)
		self.deferred.addErrback(self.handle_error)
		self.token = None
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:10,代码来源:flickr.py


示例11: __call__

 def __call__(self):
     HTTPClientFactory.__init__(self, self.page_url,
         method=self.method, agent=self.agent,
         timeout=self.defaults.interval)
     BaseMonitor.__call__(self)
     # this deferred is created above when
     # HTTPClientFactory.__init__() is called.
     d = self.deferred
     d.addCallback(self.logStatus)
     d.addErrback(self.errorHandlerPartialPage)
     d.addErrback(self.errorHandlerTimeout)
开发者ID:Darkpaw95,项目名称:pymon,代码行数:11,代码来源:monitor.py


示例12: send_json

def send_json(url, **kw):
    qurl =url+'?'+urlencode(kw.get('postdata', {}))
    # debug(0,'URLSTATS: %s',qurl)
    factory = HTTPClientFactory(str(qurl))
    factory.noisy = False
    if url.startswith('http://'):
        reactor.connectTCP(factory.host, factory.port, factory)
    elif url.startswith('https://'):
        reactor.connectSSL(factory.host, factory.port, factory, 
            ssl.ClientContextFactory())
    else:
        raise Exception('Url error: %s' %url)
    return factory
开发者ID:hosle,项目名称:tapas,代码行数:13,代码来源:util.py


示例13: flush

 def flush(self):
     scheme, host, port, path = _parse(self.url)
     factory = HTTPClientFactory(self.url, method='POST', postdata=self._buffer.getvalue())
     factory.noisy = False
     
     if scheme == 'https':
         from twisted.internet import ssl
         contextFactory = ssl.ClientContextFactory()
         reactor.connectSSL(host, port, factory, contextFactory)
     else:
         reactor.connectTCP(host, port, factory)
     
     factory.deferred.addCallbacks(self._handle, self._error)
     self._buffer = StringIO()
开发者ID:SMAC,项目名称:corelib,代码行数:14,代码来源:protocol.py


示例14: _gotConn

 def _gotConn(self, conn, url):
     factory = HTTPClientFactory(url, **kwargs)
     
     print "!!", transport
     adr = None
     p = factory.buildProtocol(adr)
     p.makeConnection(transport)
     
     def nest(x):
         print "!!"
         self._returnConn(transport)
         de.callback(x)
     
     factory.deferred.callback(nest)
开发者ID:peterbraden,项目名称:paisley-fork,代码行数:14,代码来源:paisley.py


示例15: getPage

	def getPage(url, contextFactory=None, *args, **kwargs):
		url = str(url)
		scheme, host, port, path = _parse(url)
		factory = HTTPClientFactory(url, *args, **kwargs)
		if False: # use a proxy
			host, port = 'proxy', 6060
			factory.path = url
		if scheme == 'https':
			from twisted.internet import ssl
		if contextFactory is None:
			contextFactory = ssl.ClientContextFactory()
			reactor.connectSSL(host, port, factory, contextFactory)
		else:
			reactor.connectTCP(host, port, factory)
		return factory.deferred
开发者ID:anbusekar,项目名称:owtf,代码行数:15,代码来源:proxy.py


示例16: __init__

    def __init__(self, url, method='GET', postdata=None, headers=None,
                 agent="Tor2Web (https://github.com/globaleaks/tor2web-3.0)", timeout=0, cookies=None,
                 followRedirect=1):

        headers = {}

        if url in self.cache:
            if 'last-modified' in self.cache[url]:
                headers['if-modified-since'] = self.cache[url]['last-modified']
            elif 'date' in self.cache[url]:
                headers['if-modified-since'] = self.cache[url]['date']

        HTTPClientFactory.__init__(self, url=url, method=method,
                postdata=postdata, headers=headers, agent=agent,
                timeout=timeout, cookies=cookies, followRedirect=followRedirect)
        self.deferred = Deferred()
开发者ID:Syd,项目名称:Tor2web-3.0,代码行数:16,代码来源:torExitNodes.py


示例17: __init__

 def __init__(self, ctx, *p, **k):
     """
     @param url
     @param method
     @param postdata
     @param headers
     @param timeout
     @param cookies
     @param followRedirect
     @param redirectLimit
     """
     HTTPClientFactory.__init__(self, *p, agent=self.agent, **k)
     self.finished=False
     self._ctx=ctx
     (self._amethod, self._cdic, _) = ctx
     self.eback=self._cdic["e"]
开发者ID:jldupont,项目名称:dbus_lastfm,代码行数:16,代码来源:ws.py


示例18: __init__

    def __init__(self, url, method='GET', postdata=None, headers=None,
                 agent=None, timeout=0, cookies=None, followRedirect=1):

        self.url = url

        if url in feed_storage:
            lastModified = time.ctime(feed_storage[url][0])
            if headers is not None:
                headers['last-modified'] = lastModified
            else:
                headers = {'last-modified': lastModified}

        HTTPClientFactory.__init__(self, url, method=method, postdata=postdata,
                headers=headers, agent=agent, timeout=timeout, cookies=cookies,
                followRedirect=followRedirect)

        self.waiting = True
        self.deferred = defer.Deferred()
开发者ID:lmacken,项目名称:moksha,代码行数:18,代码来源:feedstream.py


示例19: _getPage

def _getPage(url, host, port):
    """
    Fetch the body of the given url via HTTP, connecting to the given host
    and port.

    @param url: The URL to GET
    @type url: C{str}
    @param host: The hostname to connect to
    @type host: C{str}
    @param port: The port number to connect to
    @type port: C{int}
    @return: A deferred; upon 200 success the body of the response is returned,
        otherwise a twisted.web.error.Error is the result.
    """
    factory = HTTPClientFactory(url)
    factory.protocol = HTTPPageGetter
    connect(GAIEndpoint(reactor, host, port), factory)
    return factory.deferred
开发者ID:nunb,项目名称:calendarserver,代码行数:18,代码来源:wiki.py


示例20: __init__

    def __init__(self, request):
        HTTPClientFactory.__init__(self, request)
        
        self.method = request.method
        self.body = request.body or None
        self.headers = request.headers
        self.cookies = request.cookies
        
        self.start_time = time()
        self.status = None
        #self.deferred.addCallback(
        #        lambda data: (data, self.status, self.response_headers))
        self._set_connection_attributes(request)
        self.deferred = defer.Deferred().addCallback(self._build_response, request)

        if self.body is not None:
            self.headers['Content-length'] = [len(self.body)]
            # just in case a broken http/1.1 decides to keep connection alive
            self.headers.setdefault("Connection", "close")
开发者ID:llazzaro,项目名称:v12,代码行数:19,代码来源:client.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python client.HTTPConnectionPool类代码示例发布时间:2022-05-27
下一篇:
Python client.CookieAgent类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap