Small improvements
This commit is contained in:
@@ -8,6 +8,8 @@ import rich.traceback
|
||||
from rich.console import Console
|
||||
from rich.logging import RichHandler
|
||||
|
||||
from .proxy_scraper_checker import ProxyScraperChecker
|
||||
|
||||
|
||||
def install_uvloop() -> None:
|
||||
if sys.implementation.name == "cpython" and sys.platform in {
|
||||
@@ -22,24 +24,28 @@ def install_uvloop() -> None:
|
||||
uvloop.install()
|
||||
|
||||
|
||||
def setup_logging(console: Console) -> None:
|
||||
def configure_logging(console: Console) -> None:
|
||||
rich.traceback.install(console=console)
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(message)s",
|
||||
handlers=[
|
||||
RichHandler(console=console, show_path=False, rich_tracebacks=True)
|
||||
],
|
||||
handlers=(
|
||||
RichHandler(
|
||||
console=console, show_path=False, rich_tracebacks=True
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main() -> None:
|
||||
install_uvloop()
|
||||
|
||||
console = Console()
|
||||
setup_logging(console)
|
||||
|
||||
from .proxy_scraper_checker import ProxyScraperChecker
|
||||
configure_logging(console)
|
||||
|
||||
psc = ProxyScraperChecker.from_ini("config.ini", console=console)
|
||||
asyncio.run(psc.run())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -200,7 +200,7 @@ class ProxyScraperChecker:
|
||||
status = response.status
|
||||
text = await response.text()
|
||||
except Exception as e:
|
||||
logger.error("%s | %s | %s", source, e.__class__.__name__, e)
|
||||
logger.error("%s | %s | %s", source, e.__class__.__qualname__, e)
|
||||
else:
|
||||
proxies = tuple(self.regex.finditer(text))
|
||||
if proxies:
|
||||
@@ -335,9 +335,9 @@ class ProxyScraperChecker:
|
||||
for proto, proxies in self.proxies.items():
|
||||
working = len(proxies)
|
||||
total = self.proxies_count[proto]
|
||||
percentage = working / total * 100 if total else 0
|
||||
percentage = working / total if total else 0
|
||||
table.add_row(
|
||||
proto.upper(), f"{working} ({percentage:.1f}%)", str(total)
|
||||
proto.upper(), f"{working} ({percentage:.1%})", str(total)
|
||||
)
|
||||
return table
|
||||
|
||||
|
||||
Reference in New Issue
Block a user