olivia_finder.myrequests.proxy_builders
The proxy_builders subpackage
The ProxyBuilder class is an abstract base class that represents a proxy builder. It cannot be instantiated directly, but must be subclassed to create a concrete proxy builder.
Creating a Subclass
To create a subclass of ProxyBuilder, you must implement the _parse_request method. This method takes a requests.Response object as a parameter and returns a list of proxies.
Here's an example subclass that retrieves proxies from a website that provides SSL proxies:
from proxy_builder import ProxyBuilder
class SSLProxiesBuilder(ProxyBuilder):
'''
Class to represent a proxy builder that retrieves SSL proxies from a website
'''
def __init__(self, url: str = None, request_timeout: int = None):
'''
Constructor
Parameters
----------
url : str
URL of the proxy list website to get the proxies
request_timeout : int
Timeout for the proxy list requests
'''
super().__init__(url, request_timeout)
def _parse_request(self, response: requests.Response) -> List[str]:
'''
Parse the response from the SSLProxies website and return a list of proxies
Parameters
----------
response : requests.Response
The response from the request
Returns
-------
List[str]
A list of proxies
'''
# Parse the response and return a list of proxies
# ...
Using a Subclass
To use a subclass of ProxyBuilder, you can create an instance of the subclass and call its get_proxies method to retrieve a list of proxies.
Here's an example of how to use the SSLProxiesBuilder subclass:
from proxy_builders.ssl_proxies import SSLProxiesBuilder
# Create an instance of the SSLProxiesBuilder class
ssl_proxies = SSLProxiesBuilder(url='https://www.sslproxies.org/')
# Get a list of proxies from the website
proxies = ssl_proxies.get_proxies()
# Use the proxies for your application
# ...
That's a brief guide on how to use the ProxyBuilder class. Let me know if you have any questions!
Submodules of proxy_builders package:
1""" 2 3## **The proxy_builders subpackage** 4 5The `ProxyBuilder` class is an abstract base class that represents a proxy builder. It cannot be instantiated directly, but must be subclassed to create a concrete proxy builder. 6 7### Creating a Subclass 8 9To create a subclass of `ProxyBuilder`, you must implement the `_parse_request` method. This method takes a `requests.Response` object as a parameter and returns a list of proxies. 10 11Here's an example subclass that retrieves proxies from a website that provides SSL proxies: 12 13```python 14from proxy_builder import ProxyBuilder 15 16class SSLProxiesBuilder(ProxyBuilder): 17 ''' 18 Class to represent a proxy builder that retrieves SSL proxies from a website 19 ''' 20 21 def __init__(self, url: str = None, request_timeout: int = None): 22 ''' 23 Constructor 24 25 Parameters 26 ---------- 27 url : str 28 URL of the proxy list website to get the proxies 29 request_timeout : int 30 Timeout for the proxy list requests 31 ''' 32 super().__init__(url, request_timeout) 33 34 def _parse_request(self, response: requests.Response) -> List[str]: 35 ''' 36 Parse the response from the SSLProxies website and return a list of proxies 37 38 Parameters 39 ---------- 40 response : requests.Response 41 The response from the request 42 43 Returns 44 ------- 45 List[str] 46 A list of proxies 47 ''' 48 # Parse the response and return a list of proxies 49 # ... 50``` 51 52### Using a Subclass 53 54To use a subclass of `ProxyBuilder`, you can create an instance of the subclass and call its `get_proxies` method to retrieve a list of proxies. 55 56Here's an example of how to use the `SSLProxiesBuilder` subclass: 57 58```python 59from proxy_builders.ssl_proxies import SSLProxiesBuilder 60 61# Create an instance of the SSLProxiesBuilder class 62ssl_proxies = SSLProxiesBuilder(url='https://www.sslproxies.org/') 63 64# Get a list of proxies from the website 65proxies = ssl_proxies.get_proxies() 66 67# Use the proxies for your application 68# ... 69``` 70 71That's a brief guide on how to use the `ProxyBuilder` class. Let me know if you have any questions! 72 73 74Submodules of proxy_builders package: 75------------------------------------ 76 77- :class:`olivia_finder.myrequests.proxy_builders.ssl_proxies.SSLProxiesBuilder` 78- :class:`olivia_finder.myrequests.proxy_builders.list_builder.ListProxyBuilder` 79 80"""