From 08f23d92d3a216084335e5463b7479f07a7b5d1b Mon Sep 17 00:00:00 2001 From: Jesus Lara Date: Thu, 19 Sep 2024 21:57:59 +0200 Subject: [PATCH] new proxy service added --- examples/test_proxy.py | 18 ++++++++++++++++++ proxylists/proxies/__init__.py | 1 + proxylists/proxies/proxyworld.py | 28 ++++++++++++++++++++++++++++ proxylists/version.py | 2 +- 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 examples/test_proxy.py create mode 100644 proxylists/proxies/proxyworld.py diff --git a/examples/test_proxy.py b/examples/test_proxy.py new file mode 100644 index 0000000..d9e0f7d --- /dev/null +++ b/examples/test_proxy.py @@ -0,0 +1,18 @@ +import asyncio +from proxylists.proxies import ProxyWorld + + +async def proxy_list(): + proxies = await ProxyWorld().get_list() + for p in proxies: + print(p) + return proxies + + +def get_proxies(): + loop = asyncio.get_event_loop() + return loop.run_until_complete(proxy_list()) + + +if __name__ == "__main__": + get_proxies() diff --git a/proxylists/proxies/__init__.py b/proxylists/proxies/__init__.py index 0cf9bd8..40b4f34 100644 --- a/proxylists/proxies/__init__.py +++ b/proxylists/proxies/__init__.py @@ -3,6 +3,7 @@ from .freeproxy import FreeProxy from .proxydb import ProxyDB from .hidemy import Hidemy +from .proxyworld import ProxyWorld __all__ = ["FreeProxy", "Hidemy", "ProxyDB"] diff --git a/proxylists/proxies/proxyworld.py b/proxylists/proxies/proxyworld.py new file mode 100644 index 0000000..18e6d29 --- /dev/null +++ b/proxylists/proxies/proxyworld.py @@ -0,0 +1,28 @@ +# https://www.freeproxy.world/ + + +from .server import ProxyServer + + +class ProxyWorld(ProxyServer): + url = "https://www.freeproxy.world/?country=US" + table_attribute: str = 'layui-table' + table_param: str = 'class' + + async def get_proxies(self): + proxies = [] + try: + path = f'//table[@{self.table_param}="{self.table_attribute}"]' + table = self.parser.xpath(path)[0] + except IndexError as err: + print(err) + return [] + for i in table.xpath("//tbody/tr")[:10]: + if i.xpath('.//td[6]//a[contains(text(),"http")]'): + ip = i.xpath('.//td[1]/text()')[0].strip() + port = i.xpath('.//td[2]//a/text()')[0].strip() + proxy = ":".join( + [ip, port] + ) + proxies.append(proxy) + return proxies diff --git a/proxylists/version.py b/proxylists/version.py index 2600606..ef9b99a 100644 --- a/proxylists/version.py +++ b/proxylists/version.py @@ -3,7 +3,7 @@ __title__ = 'proxylists' __description__ = ('Package for getting useful proxy servers, ' 'can use lists like hidemy or proxydb.') -__version__ = '0.12.5' +__version__ = '0.13.1' __author__ = 'Jesus Lara' __author_email__ = 'jesuslarag@gmail.com' __license__ = 'BSD'