Http.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:OpenDoor 作者: potapo 项目源码 文件源码
def request(self, url):
        """Request handler"""
        # if True == self.proxy:
        #    proxyserver = self.reader.get_random_proxy()
        #    try:
        #        conn = urllib3.proxy_from_url(proxyserver, )
        #    except urllib3.exceptions.ProxySchemeUnknown as e:
        #        log.critical(e.message + ": " + proxyserver)
        # else:
        #    conn = urllib3.connection_from_url(url, )


        try:
            response = self.http.urlopen(self.DEFAULT_HTTP_METHOD, url, headers=self.HEADER, redirect=False,
                                         timeout=self.rest, release_conn=True)
        except (urllib3.exceptions.ConnectTimeoutError,
                urllib3.exceptions.MaxRetryError,
                urllib3.exceptions.HostChangedError,
                urllib3.exceptions.ReadTimeoutError,
                urllib3.exceptions.ProxyError
                ) as e:
            response = None
            self.iterator = Progress.line(url + ' -> ' + e.message, self.urls.__len__(), 'warning', self.iterator)
        except exceptions.AttributeError as e:
            log.critical(e.message)
        except TypeError as e:
            log.critical(e.message)

        time.sleep(self.delay)
        return self.response(response, url)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号