diff --git a/README.md b/README.md index cae0983..e10f250 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ ninja = Ninjemail( browser="firefox", captcha_keys={"capsolver": "YOUR_API_KEY"}, sms_keys={"service_name": {"user": "USERNAME", "token": "TOKEN"}}, - proxy='http://ip:port', + proxies=['http://ip:port', 'http://ip2:port2'], auto_proxy=True ) ``` @@ -114,7 +114,7 @@ The `captcha_keys` parameter is a dictionary that contains the **API keys for su The `sms_keys` parameter is a dictionary that contains the **API key/s for the SMS service/s**, based on `config.toml`. The default value is an empty dictionary. You can provide an API key or keys for the SMS services if required. Currently, **"getsmscode"**, **"smspool"** and **"5sim"** are supported. -The `proxy` parameter specifies the proxy server to be used for the creation of the email accounts. It should be a string in the format "http://ip:port" where "ip" is the IP address of the proxy server and "port" is the port number. +The `proxies` parameter specifies the list of proxy servers to be used for the creation of email accounts. Is optional and can accept either a single proxy server or multiple proxy servers in a list. Each proxy should be provided as a string in the format "http://ip:port," where "ip" represents the IP address of the proxy server and "port" represents the port number. The `auto_proxy` parameter is a boolean flag that determines whether Ninjemail should automatically obtain and rotate free proxies during automation tasks. If `auto_proxy` is set to `True`, Ninjemail will handle the process of acquiring and managing free proxies internally. diff --git a/ninjemail/ninjemail_manager.py b/ninjemail/ninjemail_manager.py index 628bdde..a747918 100644 --- a/ninjemail/ninjemail_manager.py +++ b/ninjemail/ninjemail_manager.py @@ -51,7 +51,7 @@ def __init__(self, browser="firefox", captcha_keys={}, sms_keys={}, - proxy=None, + proxies=None, auto_proxy=False ): """ @@ -61,7 +61,7 @@ def __init__(self, browser (str, optional): The browser to be used for automation. Default is "firefox". captcha_keys (dict, optional): The API keys for captcha solving services. Default is an empty dictionary. sms_keys (dict, optional): The API keys for SMS services. Default is an empty dictionary. - proxy (str, optional): The proxy to use for the webdriver. Default is None. + proxies (list, optional): List of proxies to use for the webdriver. Default is None. auto_proxy (bool, optional): Flag to indicate whether to use free proxies. Default is False. """ if browser not in SUPPORTED_BROWSERS: @@ -76,7 +76,7 @@ def __init__(self, self.default_sms_service = DEFAULT_SMS_SERVICE self.supported_solvers_by_email = SUPPORTED_SOLVERS_BY_EMAIL - self.proxy = proxy + self.proxies = proxies self.auto_proxy = auto_proxy #Set up logging @@ -104,8 +104,8 @@ def get_proxy(self): """ Returns a proxy if user provided one or tries to get a free proxy if auto_proxy is enabled. """ - if self.proxy: - return self.proxy + if self.proxies: + return random.choice(self.proxies) elif self.auto_proxy: try: logging.info('Getting Free Proxy..') diff --git a/ninjemail/sms_services/__init__.py b/ninjemail/sms_services/__init__.py index 615e08a..2c62574 100644 --- a/ninjemail/sms_services/__init__.py +++ b/ninjemail/sms_services/__init__.py @@ -33,6 +33,4 @@ def get_sms_instance(sms_info, email_provider): data.update({'service': email_provider}) sms_provider = fivesim.FiveSim(**data) - print(data) - return sms_provider diff --git a/ninjemail/tests/test_manager.py b/ninjemail/tests/test_manager.py index 34dd71a..49e3192 100644 --- a/ninjemail/tests/test_manager.py +++ b/ninjemail/tests/test_manager.py @@ -30,7 +30,7 @@ def test_init_invalid_browser(): def test_get_proxy_with_provided_proxy(mocker): """Tests get_proxy with a user-provided proxy.""" proxy = "http://myproxy:8080" - manager = Ninjemail(proxy=proxy) + manager = Ninjemail(proxies=[proxy]) assert manager.get_proxy() == proxy mocker.assert_not_called() # Assert FreeProxy.get wasn't called @@ -166,7 +166,7 @@ def test_create_outlook_account_no_info(): def test_create_outlook_account_with_proxy(): - manager = Ninjemail(browser='chrome', captcha_keys={'capsolver': {'token': 'aaaaaaaa'}}, proxy='http://127.0.0.1:8080') + manager = Ninjemail(browser='chrome', captcha_keys={'capsolver': {'token': 'aaaaaaaa'}}, proxies=['http://127.0.0.1:8080']) username, password = manager.create_outlook_account( ) @@ -213,7 +213,7 @@ def test_create_gmail_account_no_info(): def test_create_gmail_account_with_proxy(): - manager = Ninjemail(sms_keys={'smspool': {'token': 'aaaaaaaa'}}, proxy='http://127.0.0.1:8080') + manager = Ninjemail(sms_keys={'smspool': {'token': 'aaaaaaaa'}}, proxies=['http://127.0.0.1:8080']) username, password = manager.create_gmail_account( ) @@ -262,7 +262,7 @@ def test_create_yahoo_account_no_info(): def test_create_yahoo_account_with_proxy(): manager = Ninjemail(browser='chrome', captcha_keys={'capsolver': {'token': 'aaaaaaaa'}}, - sms_keys={'smspool': {'token': 'bbbbbb'}}, proxy='http://127.0.0.1:8080') + sms_keys={'smspool': {'token': 'bbbbbb'}}, proxies=['http://127.0.0.1:8080']) username, password = manager.create_yahoo_account( )