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
评论列表
文章目录