Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CK authored and CK committed May 16, 2024
1 parent c02963b commit ea5f311
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
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 }}
21 changes: 21 additions & 0 deletions LICENSE
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.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# captchakiller-python

## Installation
`pip install captchakiller`
`pip install captchakiller-python`

## Usage
### Import the CaptchaKiller class
Expand All @@ -26,4 +26,4 @@ if response['success']:
print("Captcha solved: " + response["result"])
else:
print("Error: " + str(response["errorId"]) + " - " + response["error"])
```
```
3 changes: 3 additions & 0 deletions captchakiller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .ck import CaptchaKiller

__version__ = "0.0.5"
103 changes: 103 additions & 0 deletions captchakiller/ck.py
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"}
14 changes: 14 additions & 0 deletions captchakiller/utils.py
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}

15 changes: 15 additions & 0 deletions examples/getbalance.py
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"])
15 changes: 15 additions & 0 deletions examples/recaptchav2.py
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"])
15 changes: 15 additions & 0 deletions examples/recaptchav2enterprise.py
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"])
15 changes: 15 additions & 0 deletions examples/recaptchav3lowscore.py
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"])
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests
33 changes: 33 additions & 0 deletions setup.py
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"
)

0 comments on commit ea5f311

Please sign in to comment.