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


Python HTTPRequest.proxy_password方法代码示例

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


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

示例1: __call__

# 需要导入模块: from tornado.httpclient import HTTPRequest [as 别名]
# 或者: from tornado.httpclient.HTTPRequest import proxy_password [as 别名]
    def __call__(self, msg, out_stream):
        """
        Work on the current `DataMessage` and send the result to `out_stream`.
        """
        # prepare the HTTPHeaders
        headers = prepare_headers(msg)

        last_modified = None
        if msg.curi.req_header:
            # check if we have a date when the page was last crawled
            if "Last-Modified" in msg.curi.req_header:
                last_modified = deserialize_date_time(
                        msg.curi.req_header["Last-Modified"])

        # check if we have username and password present
        auth_username = None
        auth_password = None
        if msg.curi.optional_vars and \
            CURI_SITE_USERNAME in msg.curi.optional_vars and \
            CURI_SITE_PASSWORD in msg.curi.optional_vars:

            auth_username = msg.curi.optional_vars[CURI_SITE_USERNAME]
            auth_password = msg.curi.optional_vars[CURI_SITE_PASSWORD]

        # create the request
        request = HTTPRequest(msg.curi.effective_url,
                method="GET",
                headers=headers,
                auth_username=auth_username,
                auth_password=auth_password,
                if_modified_since=last_modified,
                follow_redirects=self._follow_redirects,
                max_redirects=self._max_redirects,
                user_agent=self._user_agent,
                request_timeout = self._request_timeout,
                connect_timeout = self._connect_timeout,
                validate_cert = self._validate_cert)

        if hasattr(self, '_proxy_configuration'):
            request.proxy_host = self._proxy_configuration['host']
            request.proxy_port = self._proxy_configuration['port']
            request.proxy_username = \
                    self._proxy_configuration.get('user', None)
            request.proxy_password = \
                    self._proxy_configuration.get('password', None)

        LOG.info("proc.fetch::request for %s" % msg.curi.url)
        self._client.fetch(request, handle_response(msg, out_stream))
开发者ID:Big-Data,项目名称:Spyder,代码行数:50,代码来源:fetcher.py


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