proxy-reader 2.1.3__tar.gz → 2.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {proxy_reader-2.1.3/proxy_reader.egg-info → proxy_reader-2.1.5}/PKG-INFO +1 -1
  2. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader/__init__.py +1 -1
  3. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader/reader.py +24 -29
  4. {proxy_reader-2.1.3 → proxy_reader-2.1.5/proxy_reader.egg-info}/PKG-INFO +1 -1
  5. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader.egg-info/SOURCES.txt +0 -2
  6. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/pyproject.toml +2 -2
  7. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/tests/test_checker.py +4 -1
  8. proxy_reader-2.1.3/proxy_reader/protocols/__init__.py +0 -0
  9. proxy_reader-2.1.3/proxy_reader/protocols/reader.py +0 -74
  10. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/LICENSE +0 -0
  11. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/MANIFEST.in +0 -0
  12. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/README.md +0 -0
  13. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader/_types.py +0 -0
  14. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader/domains.py +0 -0
  15. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader/logs_config.py +0 -0
  16. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader/proxy.py +0 -0
  17. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader/py.typed +0 -0
  18. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader/utils.py +0 -0
  19. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader.egg-info/dependency_links.txt +0 -0
  20. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader.egg-info/requires.txt +0 -0
  21. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/proxy_reader.egg-info/top_level.txt +0 -0
  22. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/setup.cfg +0 -0
  23. {proxy_reader-2.1.3 → proxy_reader-2.1.5}/tests/test_reader.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxy-reader
3
- Version: 2.1.3
3
+ Version: 2.1.5
4
4
  Summary: Proxy reader for Python
5
5
  Project-URL: Homepage, https://github.com/runetech0/proxy-reader
6
6
  Project-URL: github, https://github.com/runetech0/proxy-reader
@@ -1,3 +1,3 @@
1
1
  from .reader import *
2
2
 
3
- __version__ = "2.1.3"
3
+ __version__ = "2.1.5"
@@ -12,18 +12,17 @@ from aiohttp_socks import ProxyConnector
12
12
 
13
13
  from ._types import ProxiesList, ProxyDictT, ProxyiesGen
14
14
  from .logs_config import logger
15
- from .protocols.reader import ProxiesReaderProtocol
16
15
  from .proxy import Proxy
17
16
  from .utils import parse_proxy_line
18
17
 
19
18
 
20
- class ProxiesReader(ProxiesReaderProtocol):
19
+ class ProxiesReader:
21
20
  def __init__(
22
21
  self,
23
22
  proxies_file: str,
24
23
  check_proxies: bool = False,
25
24
  proxy_checking_threads: int = 50,
26
- max_response_time: int = 60,
25
+ max_response_time: int = 10,
27
26
  shuffle: bool = False,
28
27
  check_urls: list[str] = [],
29
28
  ) -> None:
@@ -67,6 +66,8 @@ class ProxiesReader(ProxiesReaderProtocol):
67
66
  # "http://api.thecatapi.com/v1/images/search",
68
67
  # "http://dog.ceo/api/breeds/image/random",
69
68
  ]
69
+ self._connections_limit = 60 if "win" in sys.platform else 100
70
+ self._connector = aiohttp.TCPConnector(limit=self._connections_limit)
70
71
 
71
72
  @classmethod
72
73
  def load_list(
@@ -175,48 +176,42 @@ class ProxiesReader(ProxiesReaderProtocol):
175
176
  async def _check_proxy(
176
177
  self, proxy: Proxy, response_time: int | None = None
177
178
  ) -> bool:
178
- connectins_limit = 60 if "win" in sys.platform else 100
179
- connector = aiohttp.TCPConnector(limit=connectins_limit)
180
- session = aiohttp.ClientSession(connector=connector)
181
- url = self._random_proxy_check_url()
182
- p = proxy.http
183
-
184
179
  async with self._thread_control:
185
- logger.debug(f"Checking proxy {p} ..")
180
+ connector = aiohttp.TCPConnector(limit=self._connections_limit)
181
+ session = aiohttp.ClientSession(connector=connector)
182
+ logger.debug(f"Checking proxy {proxy} ..")
186
183
  try:
187
- # resp = await asyncio.wait_for(session.get(url, proxy=p), timeout=self._max_response_time)
188
184
  resp = await session.get(
189
- url,
190
- timeout=aiohttp.ClientTimeout(self._max_response_time),
191
- proxy=p,
185
+ self._random_proxy_check_url(),
186
+ timeout=aiohttp.ClientTimeout(
187
+ total=response_time or self._max_response_time
188
+ ),
189
+ proxy=proxy.http,
192
190
  ssl=False,
193
191
  )
194
- # await resp.read()
192
+
193
+ if resp.status in range(200, 299):
194
+ logger.debug(f"{proxy}: Working")
195
+ self._working_proxies.append(proxy)
196
+ return True
197
+
198
+ else:
199
+ logger.debug(f"{proxy}: Not Working. Response code: {resp.status}")
200
+ self._bad_proxies.append(proxy)
195
201
 
196
202
  except asyncio.TimeoutError as e:
197
203
  self._timeout_count += 1
198
- logger.debug(f"{p} : TIMEOUT {e}. {url}")
204
+ logger.debug(f"{proxy} : TIMEOUT {e}.")
199
205
  self._bad_proxies.append(proxy)
200
- await connector.close()
201
- await session.close()
202
- return False
203
206
 
204
207
  except Exception as e:
205
208
  logger.debug(f"Bad proxy raised. {e}", exc_info=True)
206
- return False
209
+ self._bad_proxies.append(proxy)
207
210
 
208
211
  finally:
209
212
  await session.close()
210
213
 
211
- if resp.status == 200:
212
- logger.debug(f"{p}: Working")
213
- self._working_proxies.append(proxy)
214
-
215
- else:
216
- logger.debug(f"{p}: Not Working. Response code: {resp.status}")
217
- self._bad_proxies.append(proxy)
218
-
219
- return True
214
+ return False
220
215
 
221
216
  async def check_all_proxies(self, max_resp_time: int = 30) -> None:
222
217
  """Run this to check all proxies at once."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: proxy-reader
3
- Version: 2.1.3
3
+ Version: 2.1.5
4
4
  Summary: Proxy reader for Python
5
5
  Project-URL: Homepage, https://github.com/runetech0/proxy-reader
6
6
  Project-URL: github, https://github.com/runetech0/proxy-reader
@@ -15,7 +15,5 @@ proxy_reader.egg-info/SOURCES.txt
15
15
  proxy_reader.egg-info/dependency_links.txt
16
16
  proxy_reader.egg-info/requires.txt
17
17
  proxy_reader.egg-info/top_level.txt
18
- proxy_reader/protocols/__init__.py
19
- proxy_reader/protocols/reader.py
20
18
  tests/test_checker.py
21
19
  tests/test_reader.py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "proxy-reader"
3
- version = "2.1.3"
3
+ version = "2.1.5"
4
4
  description = "Proxy reader for Python"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -28,7 +28,7 @@ github = "https://github.com/runetech0/proxy-reader"
28
28
 
29
29
  [tool.bumpver]
30
30
 
31
- current_version = "2.1.3"
31
+ current_version = "2.1.5"
32
32
  version_pattern = "MAJOR.MINOR.PATCH"
33
33
  commit_message = "bump version {old_version} -> {new_version}"
34
34
  tag_message = "{new_version}"
@@ -1,12 +1,15 @@
1
1
  import asyncio
2
2
 
3
+ from proxy_reader.logs_config import enable_debug_logs
3
4
  from proxy_reader.reader import ProxiesReader
4
5
 
6
+ enable_debug_logs()
7
+
5
8
 
6
9
  async def main() -> None:
7
10
  check_urls = ["https://proxy-check.queuetools.com"]
8
11
  reader = ProxiesReader("proxies.txt", check_proxies=True, check_urls=check_urls)
9
- await reader.check_all_proxies()
12
+ await reader.check_all_proxies(max_resp_time=3)
10
13
 
11
14
  print("Total working proxies:", reader.total_working)
12
15
  print("Total bad proxies:", reader.total_bad)
File without changes
@@ -1,74 +0,0 @@
1
- from typing import List, Optional, Dict, Any, Protocol
2
- from .._types import ProxiesList
3
- from ..proxy import Proxy
4
-
5
-
6
- class ProxiesReaderProtocol(Protocol):
7
- @property
8
- def total(self) -> int: ...
9
-
10
- @property
11
- def total_working(self) -> int: ...
12
-
13
- @property
14
- def total_bad(self) -> int: ...
15
-
16
- @property
17
- def proxies(self) -> ProxiesList: ...
18
-
19
- @property
20
- def bad_proxies(self) -> ProxiesList: ...
21
-
22
- @property
23
- def working_proxies(self) -> ProxiesList: ...
24
-
25
- @working_proxies.setter
26
- def working_proxies(self, working_proxies: List[Proxy]) -> None: ...
27
-
28
- def _random_proxy_check_url(self) -> str: ...
29
-
30
- def read_with_auth(self) -> None: ...
31
-
32
- def read_authless(self) -> None: ...
33
-
34
- async def _check_proxy(
35
- self, proxy: Proxy, response_time: Optional[int] = None
36
- ) -> bool: ...
37
-
38
- async def check_all_proxies(self, max_resp_time: int = 30) -> None: ...
39
-
40
- async def _check_proxy_socks(
41
- self, proxy: Proxy, response_time: Optional[int] = None
42
- ) -> bool: ...
43
-
44
- async def check_all_proxies_socks5(self, max_resp_time: int = 5) -> None: ...
45
-
46
- def get_working_proxies_list_http(self) -> List[str]: ...
47
-
48
- def write_working_proxies(self, filename: str) -> None: ...
49
-
50
- def get_random_http(self) -> Optional[str]: ...
51
-
52
- def get_random_socks5(self) -> Optional[str]: ...
53
-
54
- def get_random_socks5_telegram(self) -> Optional[Dict[str, Any]]: ...
55
-
56
- def next_http_from_list(self) -> Optional[str]: ...
57
-
58
- def next_http_from_cycle(self) -> str: ...
59
-
60
- def next_socks5_from_list(self) -> str: ...
61
-
62
- def next_socks5_from_cycle(self) -> str: ...
63
-
64
- def next_http_telegram_from_list(self) -> Dict[str, Any]: ...
65
-
66
- def next_http_telegram_from_cycle(self) -> Dict[str, Any]: ...
67
-
68
- def next_socks5_telegram_from_cycle(self) -> Dict[str, Any]: ...
69
-
70
- def next_socks5_telegram_from_list(self) -> Dict[str, Any]: ...
71
-
72
- def next_https_from_list(self) -> str: ...
73
-
74
- def next_https_from_cycle(self) -> str: ...
File without changes
File without changes
File without changes
File without changes