-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CK
authored and
CK
committed
May 16, 2024
1 parent
c02963b
commit ea5f311
Showing
12 changed files
with
269 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Upload Python Package to PyPI when a Release is Created | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
pypi-publish: | ||
name: Publish release to PyPI | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/captchakiller | ||
permissions: | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel | ||
- name: Build package | ||
run: | | ||
python setup.py sdist bdist_wheel # Could also be python -m build | ||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 captchakillernet | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .ck import CaptchaKiller | ||
|
||
__version__ = "0.0.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from .utils import _send_request | ||
|
||
class UserManager: | ||
def getbalance(self): | ||
url = self.USER_ENDPOINT + 'balance' | ||
headers = { | ||
'x-api-key': self.API_KEY | ||
} | ||
response = _send_request(self, url, {}, headers) | ||
if 'error' in response: | ||
response.update({"success": False}) | ||
return response | ||
elif 'balance' in response: | ||
response.update({"success": True}) | ||
return response | ||
else: | ||
response.update({"success": False}) | ||
return {"errorId": "0", "error": "Unknown error"} | ||
|
||
class CaptchaKiller: | ||
|
||
TIMEOUT = 30 | ||
API_KEY = '' | ||
SOLVE_ENDPOINT = 'https://api.captchakiller.net/c/' | ||
USER_ENDPOINT = 'https://api.captchakiller.net/u/' | ||
PARTNER_ID = '' | ||
|
||
def __init__(self, api_key=None, partner_id=None, timeout=30): | ||
self.API_KEY = api_key if api_key is not None else self.API_KEY | ||
self.PARTNER_ID = partner_id if partner_id is not None else self.PARTNER_ID | ||
self.TIMEOUT = timeout | ||
|
||
def getbalance(self): | ||
return UserManager.getbalance(self) | ||
|
||
def recaptcha_v2(self, sitekey, site, gdomain=False, invisible=False, payload=None): | ||
url = self.SOLVE_ENDPOINT + 'solvev2' | ||
|
||
queryparams = { | ||
'sitekey': sitekey, | ||
'site': site, | ||
'gdomain': gdomain, | ||
'invisible': invisible, | ||
'payload': payload, | ||
} | ||
|
||
response = _send_request(self, url, queryparams, {}) | ||
|
||
if 'error' in response: | ||
response.update({"success": False}) | ||
return response | ||
elif 'result' in response: | ||
response.update({"success": True}) | ||
return response | ||
else: | ||
response.update({"success": False}) | ||
return {"errorId": "0", "error": "Unknown error"} | ||
|
||
def recaptcha_v2_enterprise(self, sitekey, site, gdomain=False, invisible=False, payload=None, action=None): | ||
url = self.SOLVE_ENDPOINT + 'solvev2e' | ||
|
||
queryparams = { | ||
'sitekey': sitekey, | ||
'site': site, | ||
'gdomain': gdomain, | ||
'invisible': invisible, | ||
'payload': payload, | ||
'action': action, | ||
} | ||
|
||
response = _send_request(self, url, queryparams, {}) | ||
|
||
if 'error' in response: | ||
response.update({"success": False}) | ||
return response | ||
elif 'result' in response: | ||
response.update({"success": True}) | ||
return response | ||
else: | ||
response.update({"success": False}) | ||
return {"errorId": "0", "error": "Unknown error"} | ||
|
||
def recaptcha_v3_low_score(self, sitekey, site, action, gdomain=False): | ||
url = self.SOLVE_ENDPOINT + 'solvev3ls' | ||
|
||
queryparams = { | ||
'sitekey': sitekey, | ||
'site': site, | ||
'action': action, | ||
'gdomain': gdomain, | ||
} | ||
|
||
response = _send_request(self, url, queryparams, {}) | ||
|
||
if 'error' in response: | ||
response.update({"success": False}) | ||
return response | ||
elif 'result' in response: | ||
response.update({"success": True}) | ||
return response | ||
else: | ||
response.update({"success": False}) | ||
return {"errorId": "0", "error": "Unknown error"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import requests | ||
import json | ||
import time | ||
|
||
|
||
def _send_request(self, url, queryparams, headers=None): | ||
try: | ||
headers['x-partner-id'] = self.PARTNER_ID | ||
headers['x-api-key'] = self.API_KEY | ||
response = requests.get(url, params=queryparams, headers=headers, timeout=self.TIMEOUT) | ||
return response.json() | ||
except Exception as e: | ||
return {"error": e} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from captchakiller import CaptchaKiller | ||
|
||
captcha_killer = CaptchaKiller() | ||
|
||
""" | ||
Use custom configuration | ||
captcha_killer = CaptchaKiller("API_KEY") | ||
""" | ||
|
||
response = captcha_killer.getbalance() | ||
|
||
if response['success']: | ||
print("Balance: " + response["balance"]) | ||
else: | ||
print("Error: " + str(response["errorId"]) + " - " + response["error"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from captchakiller import CaptchaKiller | ||
|
||
captcha_killer = CaptchaKiller() | ||
|
||
""" | ||
Use custom configuration | ||
captcha_killer = CaptchaKiller("API_KEY") | ||
""" | ||
|
||
response = captcha_killer.recaptcha_v2("6LfW6wATAAAAAHLqO2pb8bDBahxlMxNdo9g947u9", "https://recaptcha-demo.appspot.com/") | ||
|
||
if response['success']: | ||
print("Captcha solved: " + response["result"]) | ||
else: | ||
print("Error: " + str(response["errorId"]) + " - " + response["error"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from captchakiller import CaptchaKiller | ||
|
||
captcha_killer = CaptchaKiller() | ||
|
||
""" | ||
Use custom configuration | ||
captcha_killer = CaptchaKiller("API_KEY") | ||
""" | ||
|
||
response = captcha_killer.recaptcha_v2_enterprise("6LfW6wATAAAAAHLqO2pb8bDBahxlMxNdo9g947u9", "https://recaptcha-demo.appspot.com/") | ||
|
||
if response['success']: | ||
print("Captcha solved: " + response["result"]) | ||
else: | ||
print("Error: " + str(response["errorId"]) + " - " + response["error"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from captchakiller import CaptchaKiller | ||
|
||
captcha_killer = CaptchaKiller() | ||
|
||
""" | ||
Use custom configuration | ||
captcha_killer = CaptchaKiller("API_KEY") | ||
""" | ||
|
||
response = captcha_killer.recaptcha_v3_low_score("6LdKlZEpAAAAAAOQjzC2v_d36tWxCl6dWsozdSy9", "https://recaptcha-demo.appspot.com/", "examples/v3scores") | ||
|
||
if response['success']: | ||
print("Captcha solved: " + response["result"]) | ||
else: | ||
print("Error: " + str(response["errorId"]) + " - " + response["error"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import setuptools | ||
|
||
with open("README.md", "r", encoding = "utf-8") as fh: | ||
long_description = fh.read() | ||
|
||
def getversion(): | ||
with open("captchakiller/__init__.py", "r", encoding = "utf-8") as fh: | ||
return fh.read().split("__version__ = \"", 1)[1].split("\"", 1)[0] | ||
|
||
setuptools.setup( | ||
name = "captchakiller-python", | ||
version = getversion(), | ||
author = "captchakiller", | ||
author_email = "support@captchakiller.net", | ||
description = "CaptchaKiller Python API Client Library, for solving captchas. Fast Recaptcha Captcha Solver", | ||
long_description = long_description, | ||
long_description_content_type = "text/markdown", | ||
url = "https://github.com/captchakillernet/captchakiller-python", | ||
project_urls = { | ||
"Homepage": "https://captchakiller.net", | ||
"Documentation": "https://captchakiller.gitbook.io", | ||
}, | ||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
], | ||
install_requires = ["requests"], | ||
packages = setuptools.find_packages(), | ||
include_package_data=True, | ||
py_modules=["captchakiller"], | ||
python_requires = ">=3.6" | ||
) |