checker.py 文件源码

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

项目:freehp 作者: jadbin 项目源码 文件源码
def check_proxy(self, addr):
        if not addr.startswith("http://"):
            proxy = "http://{0}".format(addr)
        else:
            proxy = addr
        try:
            async with aiohttp.ClientSession(loop=self._loop) as session:
                with async_timeout.timeout(self._timeout, loop=self._loop):
                    async with session.request("GET", self._url, proxy=proxy) as resp:
                        url = str(resp.url)
                        if not self.match_status(self._http_status, resp.status):
                            return False
                        if self._url_match and not self._url_match.search(url):
                            return False
                        body = await resp.read()
                        if self._body_match and not self._body_match.search(body):
                            return False
        except Exception:
            return False
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号