proxy-reader 2.0.0__py3-none-any.whl → 2.1.0__py3-none-any.whl

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.

Potentially problematic release.


This version of proxy-reader might be problematic. Click here for more details.

proxy_reader/__init__.py CHANGED
@@ -1,4 +1,3 @@
1
1
  from .reader import *
2
2
 
3
-
4
- __version__ = "2.0.0"
3
+ __version__ = "2.1.0"
proxy_reader/proxy.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
- from typing import TYPE_CHECKING, Optional, Dict, Any
3
2
 
3
+ from typing import TYPE_CHECKING, Any, Dict, Optional
4
4
 
5
5
  if TYPE_CHECKING:
6
6
  from ._types import GeneralDict, ProxyDictT
proxy_reader/reader.py CHANGED
@@ -1,18 +1,20 @@
1
+ import asyncio
2
+ import itertools
1
3
  import os
2
4
  import random
3
- import itertools
5
+ import sys
4
6
  import tempfile
5
7
  import warnings
6
- from .utils import parse_proxy_line
7
- from .proxy import Proxy
8
+ from typing import Any
9
+
8
10
  import aiohttp
9
- import asyncio
10
- from .logs_config import logger
11
11
  from aiohttp_socks import ProxyConnector
12
- import sys
13
- from typing import Optional, List, Dict, Any
12
+
14
13
  from ._types import ProxiesList, ProxyDictT, ProxyiesGen
14
+ from .logs_config import logger
15
15
  from .protocols.reader import ProxiesReaderProtocol
16
+ from .proxy import Proxy
17
+ from .utils import parse_proxy_line
16
18
 
17
19
 
18
20
  class ProxiesReader(ProxiesReaderProtocol):
@@ -39,8 +41,8 @@ class ProxiesReader(ProxiesReaderProtocol):
39
41
  [] if self._check_proxies else self._all_proxies
40
42
  )
41
43
 
42
- self._proxy_iterator: Optional[ProxyiesGen] = None
43
- self._proxy_iterator_cycle: Optional[ProxyiesGen] = None
44
+ self._proxy_iterator: ProxyiesGen | None = None
45
+ self._proxy_iterator_cycle: ProxyiesGen | None = None
44
46
  self._thread_control: asyncio.Semaphore = asyncio.Semaphore(
45
47
  proxy_checking_threads
46
48
  )
@@ -168,7 +170,7 @@ class ProxiesReader(ProxiesReaderProtocol):
168
170
  random.shuffle(self._all_proxies)
169
171
 
170
172
  async def _check_proxy(
171
- self, proxy: Proxy, response_time: Optional[int] = None
173
+ self, proxy: Proxy, response_time: int | None = None
172
174
  ) -> bool:
173
175
  connectins_limit = 60 if "win" in sys.platform else 100
174
176
  connector = aiohttp.TCPConnector(limit=connectins_limit)
@@ -223,7 +225,7 @@ class ProxiesReader(ProxiesReaderProtocol):
223
225
  logger.debug("All proxies checked.")
224
226
 
225
227
  async def _check_proxy_socks(
226
- self, proxy: Proxy, response_time: Optional[int] = None
228
+ self, proxy: Proxy, response_time: int | None = None
227
229
  ) -> bool:
228
230
  url = self._random_proxy_check_url()
229
231
  socks_connector = ProxyConnector.from_url(proxy.socks5) # type: ignore
@@ -256,7 +258,7 @@ class ProxiesReader(ProxiesReaderProtocol):
256
258
 
257
259
  async def check_all_proxies_socks5(self, max_resp_time: int = 5) -> None:
258
260
  """Run the check on all proxies at once."""
259
- tasks: List[asyncio.Task[bool]] = []
261
+ tasks: list[asyncio.Task[bool]] = []
260
262
  for proxy in self._all_proxies:
261
263
  tasks.append(
262
264
  asyncio.create_task(self._check_proxy_socks(proxy, max_resp_time))
@@ -265,8 +267,8 @@ class ProxiesReader(ProxiesReaderProtocol):
265
267
  self._proxies_checked = True
266
268
  logger.debug("All proxies checked.")
267
269
 
268
- def get_working_proxies_list_http(self) -> List[str]:
269
- working_list: List[str] = []
270
+ def get_working_proxies_list_http(self) -> list[str]:
271
+ working_list: list[str] = []
270
272
  for proxy in self._working_proxies:
271
273
  working_list.append(proxy.http)
272
274
  return working_list
@@ -278,28 +280,28 @@ class ProxiesReader(ProxiesReaderProtocol):
278
280
  f.write("\n".join([proxy.strip() for proxy in working_list]))
279
281
  logger.debug(f"Proxies written to: {filename}")
280
282
 
281
- def get_random_http(self) -> Optional[str]:
283
+ def get_random_http(self) -> str | None:
282
284
  _p = None
283
285
  if len(self._working_proxies) > 0:
284
286
  proxy = random.choice(self._working_proxies)
285
287
  _p = proxy.http
286
288
  return _p
287
289
 
288
- def get_random_socks5(self) -> Optional[str]:
290
+ def get_random_socks5(self) -> str | None:
289
291
  _p = None
290
292
  if len(self._working_proxies) > 0:
291
293
  proxy = random.choice(self._working_proxies)
292
294
  _p = proxy.socks5
293
295
  return _p
294
296
 
295
- def get_random_socks5_telegram(self) -> Optional[Dict[str, Any]]:
297
+ def get_random_socks5_telegram(self) -> dict[str, Any] | None:
296
298
  _p = None
297
299
  if len(self._working_proxies) > 0:
298
300
  proxy = random.choice(self._working_proxies)
299
301
  _p = proxy.telegram_socks5
300
302
  return _p
301
303
 
302
- def next_http_from_list(self) -> Optional[str]:
304
+ def next_http_from_list(self) -> str | None:
303
305
  """Get next proxy from proxies list"""
304
306
 
305
307
  def __iter() -> ProxyiesGen:
@@ -339,14 +341,14 @@ class ProxiesReader(ProxiesReaderProtocol):
339
341
  )
340
342
  return str(next(self._proxy_iterator_cycle).socks5)
341
343
 
342
- def next_http_telegram_from_list(self) -> Dict[str, Any]:
344
+ def next_http_telegram_from_list(self) -> dict[str, Any]:
343
345
  """Get next proxy from proxies list"""
344
346
 
345
347
  if self._proxy_iterator is None:
346
348
  self._proxy_iterator = self.__proxies_gen(self._working_proxies)
347
349
  return dict(next(self._proxy_iterator).telegram_http)
348
350
 
349
- def next_http_telegram_from_cycle(self) -> Dict[str, Any]:
351
+ def next_http_telegram_from_cycle(self) -> dict[str, Any]:
350
352
  """Get next proxy from proxies cycle"""
351
353
 
352
354
  if self._proxy_iterator is None:
@@ -355,7 +357,7 @@ class ProxiesReader(ProxiesReaderProtocol):
355
357
  )
356
358
  return dict(next(self._proxy_iterator).telegram_http)
357
359
 
358
- def next_socks5_telegram_from_cycle(self) -> Dict[str, Any]:
360
+ def next_socks5_telegram_from_cycle(self) -> dict[str, Any]:
359
361
  """Get next proxy from proxies cycle"""
360
362
  if self._proxy_iterator_cycle is None:
361
363
  self._proxy_iterator_cycle = self.__proxies_gen(
@@ -363,7 +365,7 @@ class ProxiesReader(ProxiesReaderProtocol):
363
365
  )
364
366
  return dict(next(self._proxy_iterator_cycle).telegram_socks5)
365
367
 
366
- def next_socks5_telegram_from_list(self) -> Dict[str, Any]:
368
+ def next_socks5_telegram_from_list(self) -> dict[str, Any]:
367
369
  """Get next proxy from proxies cycle"""
368
370
 
369
371
  if self._proxy_iterator_cycle is None:
@@ -389,7 +391,7 @@ class ProxiesReader(ProxiesReaderProtocol):
389
391
  return str(next(self._proxy_iterator_cycle).https)
390
392
 
391
393
  def __proxies_gen(
392
- self, proxies_list: List[Proxy], cycle_proxies: bool = False
394
+ self, proxies_list: list[Proxy], cycle_proxies: bool = False
393
395
  ) -> ProxyiesGen:
394
396
  if cycle_proxies:
395
397
  for proxy in itertools.cycle(self._working_proxies):
proxy_reader/utils.py CHANGED
@@ -1,6 +1,7 @@
1
- from ._types import ProxyDictT
2
1
  import re
3
2
  from typing import cast
3
+
4
+ from ._types import ProxyDictT
4
5
  from .logs_config import logger
5
6
 
6
7
 
@@ -8,7 +9,7 @@ def parse_proxy_line(proxy: str) -> ProxyDictT:
8
9
  """
9
10
  Detects the format of the proxy string and extracts the components.
10
11
 
11
- Returns a dictionary with 'ip_or_host', 'port', 'username', and 'password'.
12
+ Returns a dictionary with 'host', 'port', 'username', and 'password'.
12
13
  """
13
14
  logger.info("Reading the proxy format ...")
14
15
  patterns: list[str] = [
@@ -21,7 +22,7 @@ def parse_proxy_line(proxy: str) -> ProxyDictT:
21
22
  # Format 4: USERNAME:PASSWORD@IP/Hostname:PORT
22
23
  r"^(?P<username>[^:]+):(?P<password>[^@]+)@(?P<host>[\w\.-]+):(?P<port>\d+)$",
23
24
  # Format 5: IP/Hostname:PORT (No Username/Password)
24
- r"^(?P<ip_or_host>[\w\.-]+):(?P<port>\d+)$",
25
+ r"^(?P<host>[\w\.-]+):(?P<port>\d+)$",
25
26
  ]
26
27
 
27
28
  for pattern in patterns:
@@ -0,0 +1,48 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxy-reader
3
+ Version: 2.1.0
4
+ Summary: Proxy reader for Python
5
+ Project-URL: Homepage, https://github.com/runetech0/proxy-reader
6
+ Project-URL: github, https://github.com/runetech0/proxy-reader
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: aiohttp>=3.12.15
11
+ Requires-Dist: aiohttp-socks>=0.10.1
12
+ Requires-Dist: pytest>=8.4.1
13
+ Provides-Extra: test
14
+ Requires-Dist: pytest>=7.0.0; extra == "test"
15
+ Dynamic: license-file
16
+
17
+
18
+
19
+
20
+ # proxy-reader - A simple but useful bulk proxies reader and checker.
21
+
22
+ This is useful when you are working with multiple proxies and want to bulk check
23
+ these proxies before using them.
24
+ It has iterators to iterate the proxies for easy reading.
25
+
26
+
27
+ ## Installation
28
+
29
+ ```
30
+ pip install proxy-reader
31
+ ```
32
+
33
+ ## Changelogs
34
+
35
+ ### [v0.3.0]
36
+ * Add load_list class method to load proxies from list
37
+ * MAJOR: auto detect the proxies format
38
+ * Use new logging config to disable logs and prevent proxy_reader.log from creating
39
+ * Logs can be enabled from user-side
40
+ * Add option to disable proxies checking from __init__
41
+
42
+
43
+ ### [v0.2.0] - 2024-10-21
44
+
45
+ * Previous unrecorded changes
46
+
47
+
48
+ For more info/queries Telegram: [@runetech](https://t.me/runetech)
@@ -0,0 +1,15 @@
1
+ proxy_reader/__init__.py,sha256=L3-vb_-fS3dfrnunLqTxpqwIOq_ygiV8cKZpfJsXWns,45
2
+ proxy_reader/_types.py,sha256=C285ga4m1KGJ9IREBGzXp6bdOIOm87rJKu2USQ1tZG0,488
3
+ proxy_reader/domains.py,sha256=d4FUb2zw3Kg9bAjtaggEcxZA293WvVcRTgMKKPmYr1A,135662
4
+ proxy_reader/logs_config.py,sha256=SXNDi0op7Bk69qxbVsYajdSAfhhw9eTVVdf6MS2v6Ts,747
5
+ proxy_reader/proxy.py,sha256=THieTNRtZEl86ijK5nFbSqQ030alzkFFU7aSkOPr6JU,2676
6
+ proxy_reader/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ proxy_reader/reader.py,sha256=vlehkoWcgO3QoWBV2X33_HUzCzphfIogaH-Autl-USk,13519
8
+ proxy_reader/utils.py,sha256=LkRUug8Utm-zsje50L3n80V7DPJ8FSHjoyQKEPlUIOY,1451
9
+ proxy_reader/protocols/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ proxy_reader/protocols/reader.py,sha256=UbQKOPhIqRwaGpgN29-zdUs1hYOaBKCyqjgb9gQHrD0,2004
11
+ proxy_reader-2.1.0.dist-info/licenses/LICENSE,sha256=8DyHi9RsZXeM8s1DpaXubZSSG44PkzV2oskJE3E09F4,1081
12
+ proxy_reader-2.1.0.dist-info/METADATA,sha256=gWBCI39LWS5UdC08lSQ8vmyAK0ExnkAJDv_PWNbplDQ,1229
13
+ proxy_reader-2.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ proxy_reader-2.1.0.dist-info/top_level.txt,sha256=NIrKvLf5DF2_oEnj0yg84roFna2-MaJ7zE1jY2CIU0I,13
15
+ proxy_reader-2.1.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (76.0.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,54 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: proxy-reader
3
- Version: 2.0.0
4
- Summary: Read and check bulk proxies effectively
5
- Author-email: Rune Tech <runetech2024@gmail.com>
6
- License: The MIT License (MIT)
7
- Copyright © 2024 Rune Tech
8
-
9
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
- Project-URL: Homepage, https://github.com/runetech0/proxy-reader
15
- Project-URL: github, https://github.com/runetech0/proxy-reader
16
- Keywords: proxies,proxy,reader,checker,bulk
17
- Requires-Python: >=3.11
18
- Description-Content-Type: text/markdown
19
- License-File: LICENSE
20
- Requires-Dist: aiohttp>=3.10.10
21
- Requires-Dist: aiohttp_socks>=0.9.0
22
-
23
-
24
-
25
-
26
- # proxy-reader - A simple but useful bulk proxies reader and checker.
27
-
28
- This is useful when you are working with multiple proxies and want to bulk check
29
- these proxies before using them.
30
- It has iterators to iterate the proxies for easy reading.
31
-
32
-
33
- ## Installation
34
-
35
- ```
36
- pip install proxy-reader
37
- ```
38
-
39
- ## Changelogs
40
-
41
- ### [v0.3.0]
42
- * Add load_list class method to load proxies from list
43
- * MAJOR: auto detect the proxies format
44
- * Use new logging config to disable logs and prevent proxy_reader.log from creating
45
- * Logs can be enabled from user-side
46
- * Add option to disable proxies checking from __init__
47
-
48
-
49
- ### [v0.2.0] - 2024-10-21
50
-
51
- * Previous unrecorded changes
52
-
53
-
54
- For more info/queries Telegram: [@runetech](https://t.me/runetech)
@@ -1,15 +0,0 @@
1
- proxy_reader/__init__.py,sha256=vfiYXTHuR6qdMnj59SpTDv8lfyhX7BXRCJz16ejC3QI,46
2
- proxy_reader/_types.py,sha256=C285ga4m1KGJ9IREBGzXp6bdOIOm87rJKu2USQ1tZG0,488
3
- proxy_reader/domains.py,sha256=d4FUb2zw3Kg9bAjtaggEcxZA293WvVcRTgMKKPmYr1A,135662
4
- proxy_reader/logs_config.py,sha256=SXNDi0op7Bk69qxbVsYajdSAfhhw9eTVVdf6MS2v6Ts,747
5
- proxy_reader/proxy.py,sha256=R_imEwRmuHoflSsY5-SL6x840aRAGswwSYQkjUEF0MU,2676
6
- proxy_reader/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- proxy_reader/reader.py,sha256=-TM1yyZJm4KjayzYuxVwuXYSJ4AUIMimlwdxP41cNSY,13563
8
- proxy_reader/utils.py,sha256=WI-yVQF_Jjz9z-ougsHJgoXGC9fTqWwWHfwd1-7HUh4,1462
9
- proxy_reader/protocols/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- proxy_reader/protocols/reader.py,sha256=UbQKOPhIqRwaGpgN29-zdUs1hYOaBKCyqjgb9gQHrD0,2004
11
- proxy_reader-2.0.0.dist-info/LICENSE,sha256=8DyHi9RsZXeM8s1DpaXubZSSG44PkzV2oskJE3E09F4,1081
12
- proxy_reader-2.0.0.dist-info/METADATA,sha256=SUjVd02zim8EpqL5pRtrCHUgLakuIVMh0qfsGS8r4bQ,2366
13
- proxy_reader-2.0.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
14
- proxy_reader-2.0.0.dist-info/top_level.txt,sha256=NIrKvLf5DF2_oEnj0yg84roFna2-MaJ7zE1jY2CIU0I,13
15
- proxy_reader-2.0.0.dist-info/RECORD,,