Skip to content

Commit 1b87b31

Browse files
committed
fixed checkers
1 parent 5fd345b commit 1b87b31

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

checkers/base_checker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ async def _request(self, proxy_address, timeout) -> tuple:
110110
async with session.request(
111111
self.request_type, self.url, proxy=proxy_address, timeout=timeout, headers=headers) as \
112112
response:
113-
is_working = await self._check(response, checker_result)
113+
is_working = await self.validate(response, checker_result)
114114

115115
return is_working, checker_result
116116

117-
async def _check(self, response: aiohttp.ClientResponse, checker_result: CheckerResult) -> bool:
117+
async def validate(self, response: aiohttp.ClientResponse, checker_result: CheckerResult) -> bool:
118118
"""
119119
Implement this method. It will get response from url with http method you provided in constructor
120120

checkers/d3d_info_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ class D3DInfoChecker(BaseChecker):
77
def __init__(self, timeout=None):
88
super(D3DInfoChecker, self).__init__("https://test.d3d.info/ok.html", timeout=timeout)
99

10-
async def _check(self, response: aiohttp.ClientResponse, checker_result: CheckerResult):
10+
async def validate(self, response: aiohttp.ClientResponse, checker_result: CheckerResult):
1111
return (await response.text()).strip().lower() == 'ok'

checkers/google_com_checker.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import aiohttp
2+
3+
from checkers.base_checker import BaseChecker, CheckerResult
4+
5+
6+
class GoogleComChecker(BaseChecker):
7+
def __init__(self, timeout=None):
8+
super(GoogleComChecker, self).__init__("https://google.com", timeout=timeout)
9+
10+
async def validate(self, response: aiohttp.ClientResponse, checker_result: CheckerResult):
11+
'''
12+
We have already done the request and it was successful,
13+
Google returned something(maybe good response, maybe captcha, we don't care)
14+
'''
15+
return True

checkers/ipinfo_io_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class IPInfoIOChecker(BaseChecker):
66
def __init__(self, timeout=None):
77
super(IPInfoIOChecker, self).__init__("https://ipinfo.io/json", timeout=timeout)
88

9-
async def _check(self, response: aiohttp.ClientResponse, checker_result: CheckerResult) -> bool:
9+
async def validate(self, response: aiohttp.ClientResponse, checker_result: CheckerResult) -> bool:
1010
if response.status != 200:
1111
return False
1212

proxy_py/_settings.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from checkers.d3d_info_checker import D3DInfoChecker
2-
# from checkers.ipinfo_io_checker import IPInfoIOChecker
1+
from checkers.google_com_checker import GoogleComChecker
32

43

54
# enable to get more information in logs
@@ -65,8 +64,7 @@
6564
MINIMUM_NUMBER_OF_CHECKERS_PER_PROXY = 1
6665

6766
PROXY_CHECKERS = [
68-
# IPInfoIOChecker,
69-
D3DInfoChecker,
67+
GoogleComChecker,
7068
]
7169

7270
"""

statistics/statistics.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from models import Proxy, ProxyCountItem, NumberOfProxiesToProcess, db
22
from models import CollectorState, NumberOfCollectorsToProcess, ProcessorProxiesQueueSize
3-
from processor import Processor
43
from proxy_py import settings
54
import time
65
import asyncio

0 commit comments

Comments
 (0)