Comments (1)
Temporary hack:
class Base64String:
"""String mimics to bytes decoding"""
def __init__(self, base64: str) -> None:
self.base64 = base64
def decode(self, *args, **kwargs) -> str:
return self.base64
@dataclass
class ImageBase64StringCaptcha(ImageCaptcha):
"""ImageCaptcha: pass base64 string image directly"""
image: str
def __post_init__(self):
pass
def get_image_bytes(self) -> bytes:
return base64.b64decode(self.image[self.image.find(",") + 1 :])
def get_image_base64(self) -> Base64String:
return Base64String(self.image)
def get_image_type(self) -> str:
return "base64"
@classmethod
def get_type(cls) -> CaptchaType:
"""Return CaptchaType"""
return ImageCaptcha.get_type()
@classmethod
def get_solution_class(cls) -> BaseCaptchaSolution:
"""Return appropriate solution class"""
return ImageCaptcha.get_solution_class()
async def solve_image_base64_captcha(
service: AsyncCaptchaSolver, image: str, **kwargs
) -> AsyncSolvedCaptcha:
r"""Solves image CAPTCHA.
:param service: AsyncCaptchaSolver
:param image: str object containing base64 image with CAPTCHA
:param char_type: (optional) Character type.
:param is_phrase: (optional) Boolean. True if CAPTCHA contains more than one word.
:param is_case_sensitive: (optional) Boolean.
:param is_math: (optional) Boolean. True if CAPTCHA requires calculation.
:param min_len: (optional) Integer. Minimum length of the CAPTCHA's text.
:param max_len: (optional) Integer. Maximum length of the CAPTCHA's text.
:param alphabet: (optional) Alphabet used in the CAPTCHA.
:param language: (optional) Language.
:param comment: (optional) String. Text instructions for worker.
:return: :class:`AsyncSolvedCaptcha <AsyncSolvedCaptcha>` object
:rtype: unicaps.AsyncSolvedCaptcha
"""
return await service._solve_captcha_async(
ImageBase64StringCaptcha, image, **kwargs
)
async def main():
async with AsyncCaptchaSolver(CaptchaSolvingService.TWOCAPTCHA, API_KEY) as solver:
solved = await solve_image_base64_captcha(
solver,
BASE64_STRING_IMAGE,
is_phrase=False,
is_case_sensitive=True
)
print(f'CAPTCHA text: {solved.solution.text}')
await solved.report_good()
if __name__ == '__main__':
asyncio.run(main())
from unicaps.
Related Issues (13)
- ANTI_CAPTCHA ProxyError: Only IP addresses are supported HOT 1
- How to Monkey Patch BASE_URL? HOT 1
- Please add Custom2Captcha XEvil HOT 7
- Integrate capsolver.com HOT 3
- how to use unicaps in google search recaptcha
- How to integrate with selenium?
- Example for Recaptcha V2 Enterprise is not working
- Add reCAPTCHA Enterprise HOT 1
- What type of proxy should I use? My proxies are all IP addresses. Is there a recommended proxy platform? HOT 1
- Integration Request
- CaptchaGuru (cap.guru) changed the api link HOT 1
- can you look into if nocaptchaai.com api can be added? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unicaps.