├── .github └── workflows │ └── publish-to-pypi.yml ├── .gitignore ├── LICENSE ├── README.md ├── README_RU.md ├── nextcaptcha ├── __init__.py └── next.py ├── requirements.txt └── setup.py /.github/workflows/publish-to-pypi.yml: -------------------------------------------------------------------------------- 1 | name: Publish to PyPI 2 | on: push 3 | jobs: 4 | build-n-publish: 5 | permissions: 6 | id-token: write 7 | name: Build and publish to PyPI 8 | if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@master 12 | - name: Set up Python 3.10 13 | uses: actions/setup-python@v3 14 | with: 15 | python-version: "3.10" 16 | - name: Install pypa/build 17 | run: >- 18 | python -m 19 | pip install 20 | build 21 | --user 22 | - name: Build a binary wheel and a source tarball 23 | run: >- 24 | python -m 25 | build 26 | --sdist 27 | --wheel 28 | --outdir dist/ 29 | . 30 | - name: Publish to PyPI 31 | if: startsWith(github.ref, 'refs/tags') 32 | uses: pypa/gh-action-pypi-publish@release/v1 33 | with: 34 | password: ${{ secrets.PYPI_API_TOKEN }} 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | .idea/ 161 | test.py -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright © 2024 NextCaptcha, https://nextcaptcha.com 3 | 4 | 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: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | 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. 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NextCaptcha Python SDK 2 | NextCaptcha is a powerful captcha solving service that supports various types of captchas including reCAPTCHA v2, 3 | reCAPTCHA v2 Enterprise, reCAPTCHA v3, reCAPTCHA Mobile, hCaptcha, and FunCaptcha. With NextCaptcha, you can easily 4 | solve a variety of captcha challenges in your automation scripts and programs. 5 | 6 | This SDK provides a simple and easy-to-use Python interface for interacting with the NextCaptcha API. It supports all 7 | available captcha types and offers intuitive methods for solving different types of captchas. 8 | 9 | ## Installation 10 | 11 | You can install the NextCaptcha Python SDK using pip: 12 | 13 | ```shell 14 | pip install nextcaptcha-python 15 | ``` 16 | 17 | ## Usage 18 | 19 | To start using the NextCaptcha Python SDK, you first need to obtain your API key (clientKey) from the 20 | [NextCaptcha](https://dashboard.nextcaptcha.com) Dashboard. Then, you can create a NextCaptchaAPI instance: 21 | 22 | ```python 23 | from nextcaptcha import NextCaptchaAPI 24 | 25 | api = NextCaptchaAPI(client_key="YOUR_CLIENT_KEY") 26 | ``` 27 | 28 | Now, you can use the api object to solve various types of captchas. 29 | To solve reCAPTCHA v2 challenges, use the recaptchav2 method: 30 | 31 | ```python 32 | result = api.recaptchav2(website_url="https://example.com", website_key="SITE_KEY") 33 | ``` 34 | 35 | Solving reCAPTCHA v2 Enterprise 36 | To solve reCAPTCHA v2 Enterprise challenges, use the recaptchav2enterprise method: 37 | 38 | ```python 39 | result = api.recaptchav2enterprise(website_url="https://example.com", website_key="SITE_KEY") 40 | ``` 41 | 42 | Solving reCAPTCHA v3 43 | To solve reCAPTCHA v3 challenges, use the recaptchav3 method: 44 | 45 | ```python 46 | result = api.recaptchav3(website_url="https://example.com", website_key="SITE_KEY") 47 | ``` 48 | 49 | Solving reCAPTCHA Mobile 50 | To solve reCAPTCHA Mobile challenges, use the recaptcha_mobile method: 51 | 52 | ```python 53 | result = api.recaptcha_mobile(app_key="APP_KEY") 54 | ``` 55 | 56 | Solving hCaptcha 57 | To solve hCaptcha challenges, use the hcaptcha method: 58 | 59 | ```python 60 | result = api.hcaptcha(website_url="https://example.com", website_key="SITE_KEY") 61 | ``` 62 | 63 | Solving hCaptcha Enterprise 64 | To solve hCaptcha Enterprise challenges, use the hcaptcha_enterprise method: 65 | 66 | ```python 67 | result = api.hcaptcha_enterprise(website_url="https://example.com", website_key="SITE_KEY") 68 | ``` 69 | 70 | 71 | Checking Account Balance 72 | To check your NextCaptcha account balance, use the get_balance method: 73 | 74 | ```python 75 | balance = api.get_balance() 76 | print(f"Account balance: {balance}") 77 | ``` 78 | 79 | Here is a complete example of using the NextCaptcha Python SDK to solve a reCAPTCHA v2 challenge: 80 | 81 | ```python 82 | from nextcaptcha import NextCaptchaAPI 83 | 84 | CLIENT_KEY = "YOUR_CLIENT_KEY" 85 | WEBSITE_URL = "https://example.com" 86 | WEBSITE_KEY = "SITE_KEY" 87 | 88 | api = NextCaptchaAPI(client_key=CLIENT_KEY) 89 | result = api.recaptchav2(website_url=WEBSITE_URL, website_key=WEBSITE_KEY) 90 | 91 | if result["status"] == "ready": 92 | print(f"reCAPTCHA solved: {result['solution']}") 93 | else: 94 | print(f"Failed to solve reCAPTCHA: {result['error']}") 95 | ``` 96 | 97 | ## Error Handling 98 | 99 | If an error occurs while solving a captcha, the SDK will return a dictionary containing the error information. You can 100 | check the status field to determine if the request was successful. If the status is "ready", the captcha has been 101 | successfully solved and the solution will be provided in the solution field. If the status is "failed", the error field 102 | will contain a description of the error. 103 | 104 | ## Contributing 105 | 106 | If you find any bugs or have suggestions for improvement, please feel free to submit an issue or send a pull request. We 107 | welcome all contributions! 108 | 109 | ## License 110 | 111 | This project is licensed under the MIT License. For more information, please see the LICENSE file. 112 | 113 | 114 | -------------------------------------------------------------------------------- /README_RU.md: -------------------------------------------------------------------------------- 1 | # NextCaptcha Python SDK 2 | NextCaptcha - это мощный сервис для решения капч, который поддерживает различные типы капч, включая reCAPTCHA v2, 3 | reCAPTCHA v2 Enterprise, reCAPTCHA v3, reCAPTCHA Mobile, hCaptcha и FunCaptcha. С помощью NextCaptcha вы сможете легко 4 | решать различные проблемы с капчей в своих скриптах и программах автоматизации. 5 | 6 | Этот SDK предоставляет простой и удобный Python-интерфейс для взаимодействия с API NextCaptcha. Он поддерживает все 7 | все доступные типы капч и предлагает интуитивно понятные методы решения различных типов капч. 8 | 9 | ## Установка 10 | 11 | Вы можете установить NextCaptcha Python SDK с помощью pip: 12 | 13 | ```shell 14 | pip install nextcaptcha-python 15 | ``` 16 | 17 | ## Использование 18 | 19 | Чтобы начать использовать NextCaptcha Python SDK, вам сначала нужно получить свой API-ключ (clientKey) на 20 | [NextCaptcha](https://dashboard.nextcaptcha.com) Dashboard. Затем вы можете создать экземпляр NextCaptchaAPI: 21 | 22 | ```python 23 | from nextcaptcha import NextCaptchaAPI 24 | 25 | api = NextCaptchaAPI(client_key="YOUR_CLIENT_KEY") 26 | ``` 27 | 28 | Теперь вы можете использовать объект api для решения различных типов капч. 29 | Для решения задач reCAPTCHA v2 используйте метод recaptchav2: 30 | 31 | ```python 32 | result = api.recaptchav2(website_url="https://example.com", website_key="SITE_KEY") 33 | ``` 34 | 35 | Решение reCAPTCHA v2 Enterprise 36 | Чтобы решить проблемы reCAPTCHA v2 Enterprise, используйте метод recaptchav2enterprise: 37 | 38 | ```python 39 | result = api.recaptchav2enterprise(website_url="https://example.com", website_key="SITE_KEY") 40 | ``` 41 | 42 | Решение reCAPTCHA v3 43 | Для решения задач reCAPTCHA v3 используйте метод recaptchav3: 44 | 45 | ```python 46 | result = api.recaptchav3(website_url="https://example.com", website_key="SITE_KEY") 47 | ``` 48 | 49 | Решение reCAPTCHA Mobile 50 | Чтобы решить проблемы reCAPTCHA Mobile, используйте метод recaptcha_mobile: 51 | 52 | ```python 53 | result = api.recaptcha_mobile(app_key="APP_KEY") 54 | ``` 55 | 56 | Решение проблемы hCaptcha 57 | Чтобы решить проблемы с hCaptcha, используйте метод hcaptcha: 58 | 59 | ```python 60 | result = api.hcaptcha(website_url="https://example.com", website_key="SITE_KEY") 61 | ``` 62 | 63 | Решение проблем hCaptcha Enterprise 64 | Чтобы решить проблемы hCaptcha Enterprise, используйте метод hcaptcha_enterprise: 65 | 66 | ```python 67 | result = api.hcaptcha_enterprise(website_url="https://example.com", website_key="SITE_KEY") 68 | ``` 69 | 70 | Решение задач FunCaptcha 71 | Чтобы решить проблемы FunCaptcha, используйте метод funcaptcha: 72 | 73 | ```python 74 | result = api.funcaptcha(website_public_key="WEBSITE_PUBLIC_KEY") 75 | ``` 76 | 77 | Проверка баланса аккаунта 78 | Чтобы проверить баланс вашего аккаунта NextCaptcha, используйте метод get_balance: 79 | 80 | ```python 81 | balance = api.get_balance() 82 | print(f "Баланс аккаунта: {баланс}") 83 | ``` 84 | 85 | Вот полный пример использования NextCaptcha Python SDK для решения задачи reCAPTCHA v2: 86 | 87 | ```python 88 | from nextcaptcha import NextCaptchaAPI 89 | 90 | CLIENT_KEY = "YOUR_CLIENT_KEY" 91 | WEBSITE_URL = "https://example.com" 92 | КЛЮЧ_САЙТА = "КЛЮЧ_САЙТА" 93 | 94 | api = NextCaptchaAPI(client_key=CLIENT_KEY) 95 | result = api.recaptchav2(website_url=WEBSITE_URL, website_key=WEBSITE_KEY) 96 | 97 | if result["status"] == "ready": 98 | print(f "reCAPTCHA решена: {result['solution']}") 99 | else: 100 | print(f "Не удалось решить reCAPTCHA: {result['error']}") 101 | ``` 102 | 103 | ## Обработка ошибок 104 | 105 | Если при решении капчи произошла ошибка, SDK вернет словарь, содержащий информацию об ошибке. Вы можете 106 | проверить поле status, чтобы определить, был ли запрос успешным. Если статус "готов", то капча была 107 | успешно решена, и решение будет представлено в поле solution. Если статус "не удалось", в поле ошибки 108 | будет содержать описание ошибки. 109 | 110 | ## Вклад 111 | 112 | Если вы обнаружили какие-либо ошибки или у вас есть предложения по улучшению, пожалуйста, не стесняйтесь оставить проблему или отправить запрос на исправление. Мы 113 | приветствуем любой вклад! 114 | 115 | ## Лицензия 116 | 117 | Этот проект лицензируется по лицензии MIT. Для получения дополнительной информации, пожалуйста, ознакомьтесь с файлом LICENSE. 118 | 119 | 120 | 121 | 122 | Переведено с помощью www.DeepL.com/Translator (бесплатная версия) -------------------------------------------------------------------------------- /nextcaptcha/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | from .next import NextCaptchaAPI 3 | 4 | 5 | 6 | __version__ = '1.1.0' 7 | -------------------------------------------------------------------------------- /nextcaptcha/next.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import time 3 | from urllib3.util.retry import Retry 4 | from requests.adapters import HTTPAdapter 5 | import requests 6 | import urllib3 7 | 8 | logging.basicConfig(level=logging.INFO) 9 | 10 | RECAPTCHAV2_TYPE = "RecaptchaV2TaskProxyless" 11 | RECAPTCHAV2_ENTERPRISE_TYPE = "RecaptchaV2EnterpriseTaskProxyless" 12 | RECAPTCHAV2HS_ENTERPRISE_TYPE = "RecaptchaV2HSEnterpriseTaskProxyless" 13 | RECAPTCHAV3_PROXYLESS_TYPE = "RecaptchaV3TaskProxyless" 14 | RECAPTCHAV3HS_PROXYLESS_TYPE = "RecaptchaV3HSTaskProxyless" 15 | RECAPTCHAV3_TYPE = "RecaptchaV3Task" 16 | RECAPTCHA_MOBILE_PROXYLESS_TYPE = "ReCaptchaMobileTaskProxyLess" 17 | RECAPTCHA_MOBILE_TYPE = "ReCaptchaMobileTask" 18 | HCAPTCHA_TYPE = "HCaptchaTask" 19 | HCAPTCHA_PROXYLESS_TYPE = "HCaptchaTaskProxyless" 20 | HCAPTCHA_ENTERPRISE_TYPE = "HCaptchaEnterpriseTask" 21 | 22 | TIMEOUT = 45 23 | 24 | PENDING_STATUS = "pending" 25 | PROCESSING_STATUS = "processing" 26 | READY_STATUS = "ready" 27 | FAILED_STATUS = "failed" 28 | 29 | 30 | class TaskBadParametersError(Exception): 31 | pass 32 | 33 | 34 | class ApiClient: 35 | HOST = "https://api.nextcaptcha.com" 36 | 37 | def __init__(self, client_key: str, solft_id: str, callback_url: str, open_log: bool) -> None: 38 | self.client_key = client_key 39 | self.solft_id = solft_id 40 | self.callback_url = callback_url 41 | self.open_log = open_log 42 | self.session = requests.session() 43 | 44 | adapter = HTTPAdapter(pool_maxsize=1000) 45 | self.session.mount('http://', adapter) 46 | self.session.mount('https://', adapter) 47 | 48 | urllib3.disable_warnings() 49 | 50 | def _get_balance(self) -> str: 51 | resp = self.session.post(url=self.HOST + "/getBalance", json={"clientKey": self.client_key}) 52 | if resp.status_code != 200: 53 | if self.open_log: 54 | logging.error(f"Error: {resp.status_code} {resp.text}") 55 | return resp.json() 56 | if self.open_log: 57 | logging.info(f"Balance: {resp.json().get('balance')}") 58 | return resp.json().get("balance") 59 | 60 | def _send(self, task: dict) -> dict: 61 | data = { 62 | "clientKey": self.client_key, 63 | "softId": self.solft_id, 64 | "callbackUrl": self.callback_url, 65 | "task": task, 66 | } 67 | resp = self.session.post(url=self.HOST + "/createTask", json=data) 68 | if resp.status_code != 200: 69 | if self.open_log: 70 | logging.error(f"Error: {resp.status_code} {resp.text}") 71 | logging.error(f"Data: {data}") 72 | return resp.json() 73 | resp = resp.json() 74 | task_id = resp.get("taskId") 75 | if self.open_log: 76 | logging.info(f"Task {task_id} created {resp}") 77 | 78 | start_time = time.time() 79 | while True: 80 | if time.time() - start_time > TIMEOUT: 81 | return {"errorId": 12, "errorDescription": "Timeout", "status": "failed"} 82 | 83 | resp = self.session.post(url=self.HOST + "/getTaskResult", 84 | json={"clientKey": self.client_key, "taskId": task_id}) 85 | if resp.status_code != 200: 86 | if self.open_log: 87 | logging.error(f"Error: {resp.status_code} {resp.text}") 88 | return resp.json() 89 | status = resp.json().get("status") 90 | if self.open_log: 91 | logging.info(f"Task status: {status}") 92 | if status == READY_STATUS: 93 | if self.open_log: 94 | logging.info(f"Task {task_id} ready {resp.json()}") 95 | return resp.json() 96 | if status == FAILED_STATUS: 97 | if self.open_log: 98 | logging.error(f"Task {task_id} failed {resp.json()}") 99 | return resp.json() 100 | time.sleep(0.5) 101 | 102 | 103 | class NextCaptchaAPI: 104 | def __init__(self, client_key: str, solft_id: str = "", callback_url: str = "", open_log: bool = True) -> None: 105 | logging.info( 106 | f"NextCaptchaAPI created with clientKey={client_key} solftId={solft_id} callbackUrl={callback_url}") 107 | self.api = ApiClient(client_key=client_key, solft_id=solft_id, callback_url=callback_url, open_log=open_log) 108 | 109 | def recaptchav2(self, website_url: str, website_key: str, recaptcha_data_s_value: str = "", 110 | is_invisible: bool = False, api_domain: str = "", page_action: str = "", 111 | website_info: str = "") -> dict: 112 | """ 113 | Solve reCAPTCHA v2 challenge. 114 | 115 | :param website_url: The URL of the website where the reCAPTCHA is located. 116 | :param website_key: The sitekey of the reCAPTCHA. 117 | :param recaptcha_data_s_value: Optional. The value of the 'data-s' parameter if present. 118 | :param is_invisible: Optional. Whether the reCAPTCHA is invisible or not. 119 | :param api_domain: Optional. The domain of the reCAPTCHA API if different from the default. 120 | :return: A dictionary containing the solution of the reCAPTCHA. 121 | """ 122 | task = { 123 | "type": RECAPTCHAV2_TYPE, 124 | "websiteURL": website_url, 125 | "websiteKey": website_key, 126 | "recaptchaDataSValue": recaptcha_data_s_value, 127 | "isInvisible": is_invisible, 128 | "apiDomain": api_domain, 129 | "pageAction": page_action, 130 | "websiteInfo": website_info 131 | } 132 | return self.api._send(task) 133 | 134 | def recaptchav2enterprise(self, website_url: str, website_key: str, enterprise_payload: dict = {}, 135 | is_invisible: bool = False, api_domain: str = "", page_action: str = "", 136 | website_info: str = "") -> dict: 137 | """ 138 | Solve reCAPTCHA v2 Enterprise challenge. 139 | 140 | :param website_url: The URL of the website where the reCAPTCHA is located. 141 | :param website_key: The sitekey of the reCAPTCHA. 142 | :param enterprise_payload: Optional. Additional enterprise payload parameters. 143 | :param is_invisible: Optional. Whether the reCAPTCHA is invisible or not. 144 | :param api_domain: Optional. The domain of the reCAPTCHA API if different from the default. 145 | :return: A dictionary containing the solution of the reCAPTCHA. 146 | """ 147 | task = { 148 | "type": RECAPTCHAV2_ENTERPRISE_TYPE, 149 | "websiteURL": website_url, 150 | "websiteKey": website_key, 151 | "enterprisePayload": enterprise_payload, 152 | "isInvisible": is_invisible, 153 | "apiDomain": api_domain, 154 | "pageAction": page_action, 155 | "websiteInfo": website_info 156 | 157 | } 158 | return self.api._send(task) 159 | 160 | def recaptchav2hs_enterprise(self, website_url: str, website_key: str, enterprise_payload: dict = {}, 161 | is_invisible: bool = False, api_domain: str = "", page_action: str = "", 162 | website_info: str = "") -> dict: 163 | """ 164 | Solve reCAPTCHA v2 Enterprise challenge. 165 | 166 | :param website_url: The URL of the website where the reCAPTCHA is located. 167 | :param website_key: The sitekey of the reCAPTCHA. 168 | :param enterprise_payload: Optional. Additional enterprise payload parameters. 169 | :param is_invisible: Optional. Whether the reCAPTCHA is invisible or not. 170 | :param api_domain: Optional. The domain of the reCAPTCHA API if different from the default. 171 | :return: A dictionary containing the solution of the reCAPTCHA. 172 | """ 173 | task = { 174 | "type": RECAPTCHAV2HS_ENTERPRISE_TYPE, 175 | "websiteURL": website_url, 176 | "websiteKey": website_key, 177 | "enterprisePayload": enterprise_payload, 178 | "isInvisible": is_invisible, 179 | "apiDomain": api_domain, 180 | "pageAction": page_action, 181 | "websiteInfo": website_info 182 | 183 | } 184 | return self.api._send(task) 185 | 186 | def recaptchav3(self, website_url: str, website_key: str, page_action: str = "", api_domain: str = "", 187 | proxy_type: str = "", proxy_address: str = "", proxy_port: int = 0, proxy_login: str = "", 188 | proxy_password: str = "", website_info: str = "") -> dict: 189 | """ 190 | Solve reCAPTCHA v3 challenge. 191 | 192 | :param website_url: The URL of the website where the reCAPTCHA is located. 193 | :param website_key: The sitekey of the reCAPTCHA. 194 | :param page_action: Optional. The action parameter to use for the reCAPTCHA. 195 | :param api_domain: Optional. The domain of the reCAPTCHA API if different from the default. 196 | :param proxy_type: Optional. The type of the proxy (HTTP, HTTPS, SOCKS4, SOCKS5). 197 | :param proxy_address: Optional. The address of the proxy. 198 | :param proxy_port: Optional. The port of the proxy. 199 | :param proxy_login: Optional. The login for the proxy. 200 | :param proxy_password: Optional. The password for the proxy. 201 | :return: A dictionary containing the solution of the reCAPTCHA. 202 | """ 203 | task = { 204 | "type": RECAPTCHAV3_PROXYLESS_TYPE, 205 | "websiteURL": website_url, 206 | "websiteKey": website_key, 207 | "pageAction": page_action, 208 | "apiDomain": api_domain, 209 | "websiteInfo": website_info 210 | 211 | } 212 | if proxy_address: 213 | task["type"] = RECAPTCHAV3_TYPE 214 | task["proxyType"] = proxy_type 215 | task["proxyAddress"] = proxy_address 216 | task["proxyPort"] = proxy_port 217 | task["proxyLogin"] = proxy_login 218 | task["proxyPassword"] = proxy_password 219 | return self.api._send(task) 220 | 221 | def recaptchav3hs(self, website_url: str, website_key: str, page_action: str = "", api_domain: str = "", 222 | website_info: str = "") -> dict: 223 | """ 224 | Solve reCAPTCHA v3 challenge. 225 | 226 | :param website_url: The URL of the website where the reCAPTCHA is located. 227 | :param website_key: The sitekey of the reCAPTCHA. 228 | :param page_action: Optional. The action parameter to use for the reCAPTCHA. 229 | :param api_domain: Optional. The domain of the reCAPTCHA API if different from the default. 230 | :param proxy_type: Optional. The type of the proxy (HTTP, HTTPS, SOCKS4, SOCKS5). 231 | :param proxy_address: Optional. The address of the proxy. 232 | :param proxy_port: Optional. The port of the proxy. 233 | :param proxy_login: Optional. The login for the proxy. 234 | :param proxy_password: Optional. The password for the proxy. 235 | :return: A dictionary containing the solution of the reCAPTCHA. 236 | """ 237 | task = { 238 | "type": RECAPTCHAV3HS_PROXYLESS_TYPE, 239 | "websiteURL": website_url, 240 | "websiteKey": website_key, 241 | "pageAction": page_action, 242 | "apiDomain": api_domain, 243 | "websiteInfo": website_info 244 | 245 | } 246 | return self.api._send(task) 247 | 248 | def recaptcha_mobile(self, app_key: str, app_package_name: str = "", app_action: str = "", proxy_type: str = "", 249 | proxy_address: str = "", proxy_port: int = 0, proxy_login: str = "", 250 | proxy_password: str = "", app_device: str = "ios") -> dict: 251 | """ 252 | Solve Mobile reCAPTCHA challenge. 253 | 254 | :param app_key: The app key of the Mobile reCAPTCHA. 255 | :param app_package_name: Optional. The package name of the mobile app. 256 | :param app_action: Optional. The action parameter to use for the Mobile reCAPTCHA. 257 | :return: A dictionary containing the solution of the Mobile reCAPTCHA. 258 | """ 259 | task = { 260 | "type": RECAPTCHA_MOBILE_PROXYLESS_TYPE, 261 | "appKey": app_key, 262 | "appPackageName": app_package_name, 263 | "appAction": app_action, 264 | "appDevice": app_device, 265 | } 266 | if proxy_address != "": 267 | task["type"] = RECAPTCHA_MOBILE_TYPE 268 | task["proxyType"] = proxy_type 269 | task["proxyAddress"] = proxy_address 270 | task["proxyPort"] = proxy_port 271 | task["proxyLogin"] = proxy_login 272 | task["proxyPassword"] = proxy_password 273 | return self.api._send(task) 274 | 275 | def hcaptcha(self, website_url: str, website_key: str, is_invisible: bool = False, enterprise_payload: dict = {}, 276 | proxy_type: str = "", proxy_address: str = "", proxy_port: int = 0, proxy_login: str = "", 277 | proxy_password: str = "") -> dict: 278 | """ 279 | Solve hCaptcha challenge. 280 | 281 | :param website_url: The URL of the website where the hCaptcha is located. 282 | :param website_key: The sitekey of the hCaptcha. 283 | :param is_invisible: Optional. Whether the hCaptcha is invisible or not. 284 | :param enterprise_payload: Optional. Additional enterprise payload parameters. 285 | :param proxy_type: Optional. The type of the proxy (HTTP, HTTPS, SOCKS4, SOCKS5). 286 | :param proxy_address: Optional. The address of the proxy. 287 | :param proxy_port: Optional. The port of the proxy. 288 | :param proxy_login: Optional. The login for the proxy. 289 | :param proxy_password: Optional. The password for the proxy. 290 | :return: A dictionary containing the solution of the hCaptcha. 291 | """ 292 | task = { 293 | "type": HCAPTCHA_PROXYLESS_TYPE, 294 | "websiteURL": website_url, 295 | "websiteKey": website_key, 296 | "isInvisible": is_invisible, 297 | "enterprisePayload": enterprise_payload, 298 | } 299 | if proxy_address: 300 | task["type"] = HCAPTCHA_TYPE 301 | task["proxyType"] = proxy_type 302 | task["proxyAddress"] = proxy_address 303 | task["proxyPort"] = proxy_port 304 | task["proxyLogin"] = proxy_login 305 | task["proxyPassword"] = proxy_password 306 | return self.api._send(task) 307 | 308 | def hcaptcha_enterprise(self, website_url: str, website_key: str, enterprise_payload: dict = {}, 309 | is_invisible: bool = False, proxy_type: str = "", proxy_address: str = "", 310 | proxy_port: int = 0, proxy_login: str = "", proxy_password: str = "") -> dict: 311 | """ 312 | Solve hCaptcha Enterprise challenge. 313 | 314 | :param website_url: The URL of the website where the hCaptcha is located. 315 | :param website_key: The sitekey of the hCaptcha. 316 | :param enterprise_payload: Optional. Additional enterprise payload parameters. 317 | :param is_invisible: Optional. Whether the hCaptcha is invisible or not. 318 | :param proxy_type: Optional. The type of the proxy (HTTP, HTTPS, SOCKS4, SOCKS5). 319 | :param proxy_address: Optional. The address of the proxy. 320 | :param proxy_port: Optional. The port of the proxy. 321 | :param proxy_login: Optional. The login for the proxy. 322 | :param proxy_password: Optional. The password for the proxy. 323 | :return: A dictionary containing the solution of the hCaptcha. 324 | """ 325 | task = { 326 | "type": HCAPTCHA_ENTERPRISE_TYPE, 327 | "websiteURL": website_url, 328 | "websiteKey": website_key, 329 | "enterprisePayload": enterprise_payload, 330 | "isInvisible": is_invisible, 331 | "proxyType": proxy_type, 332 | "proxyAddress": proxy_address, 333 | "proxyPort": proxy_port, 334 | "proxyLogin": proxy_login, 335 | "proxyPassword": proxy_password, 336 | } 337 | return self.api._send(task) 338 | 339 | def get_balance(self) -> str: 340 | """ 341 | Get the account balance. 342 | 343 | :return: A string representing the account balance. 344 | """ 345 | return self.api._get_balance() 346 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests>=2.20.0 -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import re 4 | 5 | from setuptools import setup, find_packages 6 | 7 | with open("README.md", "r") as fh: 8 | long_description = fh.read() 9 | 10 | 11 | def get_version(): 12 | with open('nextcaptcha/__init__.py', 'r') as f: 13 | return re.search(r'__version__ = ["\'](.*?)["\']', f.read()).group(1) 14 | 15 | 16 | setup(name='nextcaptcha-python', 17 | version=get_version(), 18 | description='NextCaptcha Captcha Solving Service Api Wrapper for Python to solving recaptcha v2, v3,recapthcha moible,hcaptcha,funcaptcha', 19 | long_description=long_description, 20 | long_description_content_type="text/markdown", 21 | url='https://github.com/nextcaptcha/nextcaptcha-python/', 22 | install_requires=['requests'], 23 | author='nextcaptcha', 24 | author_email='support@nextcaptcha.com', 25 | packages=find_packages(), 26 | include_package_data=True, 27 | classifiers=[ 28 | "Programming Language :: Python :: 3", 29 | "License :: OSI Approved :: MIT License", 30 | "Operating System :: OS Independent", 31 | ], 32 | python_requires='>=3.6', 33 | test_suite='tests') 34 | --------------------------------------------------------------------------------