Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
monosans committed Jan 18, 2024
1 parent 5dc1805 commit 174e02d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions proxy_scraper_checker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import aiofiles
import rich.traceback
from aiohttp import ClientSession
from aiohttp import ClientSession, TCPConnector
from rich.console import Console
from rich.logging import RichHandler
from typing_extensions import Any
Expand Down Expand Up @@ -73,7 +73,10 @@ async def main() -> None:
console = Console()
configure_logging(console, debug=cfg["debug"])

async with ClientSession(cookie_jar=constants.get_cookie_jar()) as s:
async with ClientSession(
connector=TCPConnector(ssl=constants.SSL_CONTEXT),
cookie_jar=constants.get_cookie_jar(),
) as s:
settings = await Settings.from_dict(cfg, session=s)
await ProxyScraperChecker(
console=console, session=s, settings=settings
Expand Down
4 changes: 4 additions & 0 deletions proxy_scraper_checker/constants.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from __future__ import annotations

import ssl
from functools import lru_cache
from pathlib import Path
from types import MappingProxyType

import certifi
import platformdirs
from aiohttp import DummyCookieJar, hdrs

GEODB_URL = "https://raw.githubusercontent.com/P3TERX/GeoLite.mmdb/download/GeoLite2-City.mmdb"
CACHE_DIR = platformdirs.user_cache_dir("proxy_scraper_checker")
GEODB_PATH = Path(CACHE_DIR, "GeoLite2-City.mmdb")
GEODB_ETAG_PATH = Path(CACHE_DIR, "GeoLite2-City.mmdb.etag")
SSL_CONTEXT = ssl.create_default_context(cafile=certifi.where())


HEADERS: MappingProxyType[str, str] = MappingProxyType({
hdrs.USER_AGENT: (
Expand Down
3 changes: 2 additions & 1 deletion proxy_scraper_checker/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from aiohttp import ClientSession
from aiohttp_socks import ProxyConnector, ProxyType

from .constants import HEADERS, get_cookie_jar
from .constants import HEADERS, SSL_CONTEXT, get_cookie_jar
from .parsers import parse_ipv4
from .settings import CheckWebsiteType, Settings

Expand Down Expand Up @@ -40,6 +40,7 @@ async def check(self, settings: Settings) -> None:
port=self.port,
username=self.username,
password=self.password,
ssl=SSL_CONTEXT,
)
async with ClientSession(
connector=connector,
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ aiofiles>=0.8,<24
aiohttp-socks>=0.3.1,<0.9
aiohttp[speedups]>=3.4,<4
attrs>=21.3.0
certifi
maxminddb>=2.5,<3
platformdirs<5
rich>=12.3,<14
Expand Down

0 comments on commit 174e02d

Please sign in to comment.