pool.py 文件源码

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

项目:freehp 作者: jadbin 项目源码 文件源码
def _update_proxy_list(self):
        try:
            self.params['detail'] = ''
            async with aiohttp.ClientSession(loop=self.loop) as session:
                with async_timeout.timeout(self.timeout, loop=self.loop):
                    async with session.request('GET',
                                               self.agent_addr,
                                               auth=self.auth,
                                               params=self.params) as resp:
                        body = await resp.read()
                        proxies = json.loads(body.decode('utf-8'))

                        self._remove_block()
                        t = time.time()
                        for p in proxies:
                            r = 0.8 * (p['success'] / (p['success'] + p['fail'] + 1.0))
                            proxy = PoolProxyInfo(p['addr'], t, base_rate=r)
                            self._add_new_proxy(proxy)
        except Exception:
            log.warning("Error occurred when get proxy list", exc_info=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号