Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Examples of API requests for different captcha types are available on the [Pytho
- [VKCaptcha](#vkcaptcha)
- [CaptchaFox](#captchafox)
- [Prosopo](#prosopo)
- [Temu](#temu)
- [CyberSiARA](#cybersiara)
- [Other methods](#other-methods)
- [send / get\_result](#send--get_result)
Expand Down Expand Up @@ -498,6 +499,19 @@ result = solver.prosopo(sitekey='5EZVvsHMrKCFKp5NYNoTyDjTjetoVo1Z4UNNb1DkVLS0Jbq
)
```

### Temu

<sup>[API method description.](https://2captcha.com/ru/2captcha-api#temucaptcha)</sup>

This method can be used to solve Temu captcha. Returns a coordinates.

```python
result = solver.temu(body="data:image/png;base64,iVBORw0KG...",
part1="data:image/png;base64,iVBORw0KG...",
part2="data:image/png;base64,iVBORw0KG...",
part3="data:image/png;base64,iVBORw0KG...")
```

### CyberSiARA

<sup>[API method description.](https://2captcha.com/2captcha-api#cybersiara)</sup>
Expand Down
47 changes: 47 additions & 0 deletions examples/async/async_temu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import asyncio
import os
import sys
from base64 import b64encode

import aiofiles

sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))

from twocaptcha import AsyncTwoCaptcha

# in this example we store the API key inside environment variables that can be set like:
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
# you can just set the API key directly to it's value like:
# api_key="1abc234de56fab7c89012d34e56fa7b8"

api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')

solver = AsyncTwoCaptcha(api_key)


async def solve_captcha():
# Read file and convert to base64
with open('../images/temu_main.png', 'rb') as f:
body = b64encode(f.read()).decode('utf-8')
with open('../images/temu_part1.png', 'rb') as f:
part1 = b64encode(f.read()).decode('utf-8')
with open('../images/temu_part2.png', 'rb') as f:
part2 = b64encode(f.read()).decode('utf-8')
with open('../images/temu_part3.png', 'rb') as f:
part3 = b64encode(f.read()).decode('utf-8')

try:
return await solver.temu(
body,
part1,
part2,
part3
)
except Exception as e:
sys.exit(e)


if __name__ == '__main__':
result = asyncio.run(solve_captcha())
sys.exit('result: ' + str(result))
Binary file added examples/images/temu_main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/temu_part1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/temu_part2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/temu_part3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions examples/sync/temu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sys
import os
from base64 import b64encode

sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))

from twocaptcha import TwoCaptcha

# in this example we store the API key inside environment variables that can be set like:
# export APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
# set APIKEY_2CAPTCHA=1abc234de56fab7c89012d34e56fa7b8 on Windows
# you can just set the API key directly to it's value like:
# api_key="1abc234de56fab7c89012d34e56fa7b8"

api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')

solver = TwoCaptcha(api_key)

with open('../images/temu_main.png', 'rb') as f:
body = b64encode(f.read()).decode('utf-8')
with open('../images/temu_part1.png', 'rb') as f:
part1 = b64encode(f.read()).decode('utf-8')
with open('../images/temu_part2.png', 'rb') as f:
part2 = b64encode(f.read()).decode('utf-8')
with open('../images/temu_part3.png', 'rb') as f:
part3 = b64encode(f.read()).decode('utf-8')

try:
result = solver.temu(body,
part1,
part2,
part3)

except Exception as e:
sys.exit(str(e))

else:
sys.exit('result: ' + str(result))
32 changes: 32 additions & 0 deletions tests/async/test_async_temu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3

import unittest

try:
from .abstract_async import AsyncAbstractTest
except ImportError:
from abstract_async import AsyncAbstractTest


class AsyncTemuTest(AsyncAbstractTest):
def test_all_params(self):
params = {
'body': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part1': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part2': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part3': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
}

sends = {
'method': 'temuimage',
'body': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part1': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part2': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part3': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
}

self.send_return(sends, self.solver.lemin, **params)


if __name__ == '__main__':
unittest.main()
34 changes: 34 additions & 0 deletions tests/sync/test_temu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3

import unittest

try:
from .abstract import AbstractTest

except ImportError:
from abstract import AbstractTest


class TemuTest(AbstractTest):

def test_all_params(self):
params = {
'body': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part1': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part2': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part3': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
}

sends = {
'method': 'temuimage',
'body': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part1': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part2': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'part3': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
}

return self.send_return(sends, self.solver.temu, **params)


if __name__ == '__main__':
unittest.main()
23 changes: 23 additions & 0 deletions twocaptcha/async_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,29 @@ async def prosopo(self, sitekey, pageurl, **kwargs):
**kwargs)
return result

async def temu(self, body, part1, part2, part3, **kwargs):
'''Wrapper for solving Temu captcha .

Parameters
__________
body : str
Main captcha image as a base64 string.
part1 : str
Tile element as a base64 string.
part2 : str
Tile element as a base64 string.
part3 : str
Tile element as a base64 string.
'''

result = await self.solve(method='temuimage',
body=body,
part1=part1,
part2=part2,
part3=part3,
**kwargs)
return result

async def datadome(self, captcha_url, pageurl, userAgent, proxy, **kwargs):
"""Wrapper for solving DataDome Captcha.

Expand Down
23 changes: 23 additions & 0 deletions twocaptcha/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,29 @@ def prosopo(self, sitekey, pageurl, **kwargs):
**kwargs)
return result

def temu(self, body, part1, part2, part3, **kwargs):
'''Wrapper for solving Temu captcha .

Parameters
__________
body : str
Main captcha image as a base64 string.
part1 : str
Tile element as a base64 string.
part2 : str
Tile element as a base64 string.
part3 : str
Tile element as a base64 string.
'''

result = self.solve(method='temuimage',
body=body,
part1=part1,
part2=part2,
part3=part3,
**kwargs)
return result

def datadome(self, captcha_url, pageurl, userAgent, proxy, **kwargs):
"""Wrapper for solving DataDome Captcha.

Expand Down