block: optimising for RKS large pattern list
This commit is contained in:
parent
293d83cc1c
commit
bbf070339a
2 changed files with 9 additions and 6 deletions
|
@ -23,13 +23,16 @@ class BlockMirrorAutomation(BaseAutomation):
|
|||
|
||||
def automate(self, full: bool = False) -> Tuple[bool, str]:
|
||||
self.fetch()
|
||||
logging.debug("Fetch complete")
|
||||
self.parse()
|
||||
logging.debug("Parse complete")
|
||||
rotated = list()
|
||||
for pattern in self.patterns:
|
||||
for proxy in active_proxies():
|
||||
if proxy.url is None:
|
||||
# Not ready yet
|
||||
continue
|
||||
for proxy in active_proxies():
|
||||
if proxy.url is None:
|
||||
# Not ready yet
|
||||
continue
|
||||
logging.debug("Testing active proxy %s", proxy.url)
|
||||
for pattern in self.patterns:
|
||||
if fnmatch(proxy.url, pattern):
|
||||
logging.debug("Found %s blocked", proxy.url)
|
||||
if not proxy.origin.auto_rotation:
|
||||
|
|
|
@ -23,7 +23,7 @@ class BlockRoskomsvobodaAutomation(BlockMirrorAutomation):
|
|||
_data: Any
|
||||
|
||||
def fetch(self) -> None:
|
||||
self._data = requests.get("https://reestr.rublacklist.net/api/v2/domains/json").json()
|
||||
self._data = requests.get("https://reestr.rublacklist.net/api/v2/domains/json/").json()
|
||||
|
||||
def parse(self) -> None:
|
||||
self.patterns.extend(["https://" + pattern for pattern in self._data])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue