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
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Examples of API requests for different captcha types are available on the [Pytho
- [Cutcaptcha](#cutcaptcha)
- [Tencent](#tencent)
- [DataDome](#datadome)
- [VKImage](#vkimage)
- [VKCaptcha](#vkcaptcha)
- [CaptchaFox](#captchafox)
- [Prosopo](#prosopo)
- [CyberSiARA](#cybersiara)
- [Other methods](#other-methods)
- [send / get\_result](#send--get_result)
Expand Down Expand Up @@ -440,6 +444,60 @@ result = solver.datadome(captcha_url="https://geo.captcha-delivery.com/captcha/?
param1=..., ...)
```

### VKImage

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

This method can be used to solve VK captcha using graphical captcha. Returns the number of steps and solution value in the target site's API format.

```python
result = solver.vkimage('path/to/captcha.jpg', steps='[5,4,7,7,14,22,8,...]', ...)
```

### VKCaptcha

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

This method can be used to solve VK Captcha using a token. Returns a token.

> [!IMPORTANT]
> To solve the VK Captcha, you must use a proxy. It is recommended to use [residential proxies].

```python
result = solver.vkcaptcha(redirect_uri='https://id.vk.ru/...',
userAgent='Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36..',
proxy={
'type': 'HTTP',
'uri': 'login:password@IP_address:PORT'}
)
```

### CaptchaFox

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

This method can be used to solve CaptchaFox using a token. Returns a token.

```python
result = solver.captchafox(sitekey='sk_ILKWNruBBVKDOM7dZs59KHnDLEWiH',
pageurl='https://mysite.com/page/with/captchafox',
userAgent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
proxy={'type': 'HTTPS',
'uri': 'login:password@IP_address:PORT'})
```

### Prosopo

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

This method can be used to solve Prosopo captcha using a token. Returns a token.

```python
result = solver.prosopo(sitekey='5EZVvsHMrKCFKp5NYNoTyDjTjetoVo1Z4UNNb1DkVLS0JbqR',
pageurl='https://mysite.com/page/with/prosopo'
)
```

### CyberSiARA

<sup>[API method description.](https://2captcha.com/2captcha-api#cybersiara)</sup>
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_amazon_waf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ async def solve_captcha():
url='https://efw47fpad9.execute-api.us-east-1.amazonaws.com/latest',
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_amazon_waf_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ async def solve_amazon_waf():
# }
)
except Exception as e:
print(e)
raise e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_atb_captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ async def solve_captcha():
url='http://mysite.com/',
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_atb_captcha_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ async def solve_captcha():
# }
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ async def solve_captcha():
try:
return await solver.audio('../audio/example.mp3', lang='en')
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ async def solve_captcha():
try:
return await solver.canvas('../images/canvas.jpg', hintText='Draw around apple')
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_canvas_base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ async def solve_captcha():
try:
return await solver.canvas(b64, hintText='Draw around apple')
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_canvas_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ async def solve_captcha():
hintText='Draw around apple',
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
33 changes: 33 additions & 0 deletions examples/async/async_captchafox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import asyncio
import sys
import os

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():
try:
return await solver.captchafox(
sitekey='sk_ILKWNruBBVKDOM7dZs59KHnDLEWiH',
pageurl='https://mysite.com/page/with/captchafox',
userAgent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
proxy={'type': 'HTTPS',
'uri': 'login:password@IP_address:PORT'}
)
except Exception as e:
sys.exit(e)

if __name__ == '__main__':
result = asyncio.run(solve_captcha())
sys.exit('result: ' + str(result))
42 changes: 42 additions & 0 deletions examples/async/async_captchafox_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import asyncio
import sys
import os

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')

config = {
'server': '2captcha.com', # can be also set to 'rucaptcha.com'
'apiKey': api_key,
'softId': 123,
'defaultTimeout': 120,
'recaptchaTimeout': 600,
'pollingInterval': 10,
}

solver = AsyncTwoCaptcha(**config)

async def solve_captcha():
try:
return await solver.captchafox(
sitekey='sk_ILKWNruBBVKDOM7dZs59KHnDLEWiH',
pageurl='https://mysite.com/page/with/captchafox',
userAgent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
proxy={'type': 'HTTPS',
'uri': 'login:password@IP_address:PORT'}
)
except Exception as e:
sys.exit(e)

if __name__ == '__main__':
result = asyncio.run(solve_captcha())
sys.exit('result: ' + str(result))
3 changes: 1 addition & 2 deletions examples/async/async_capy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ async def solve_captcha():
api_server="https://jp.api.capy.me/",
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_capy_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ async def solve_captcha():
api_server="https://jp.api.capy.me/",
softId=33112)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ async def solve_captcha():
try:
return await solver.coordinates('../images/grid.jpg')
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_coordinates_base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ async def solve_captcha():
try:
return await solver.coordinates(b64)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_coordinates_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ async def solve_captcha():
min_clicks=2,
max_clicks=3)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_cutcaptcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ async def solve_captcha():
url='https://mysite.com/page/with/cutcaptcha',
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_cutcaptcha_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ async def solve_captcha():
# }
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_cybersiara.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ async def solve_captcha():
userAgent='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36',
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_datadome.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ async def solve_captcha():
}
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_friendly_captcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ async def solve_captcha():
url='https://friendlycaptcha.com/demo',
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_friendly_captcha_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ async def solve_captcha():
# }
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_funcaptcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ async def solve_captcha():
surl='https://client-api.arkoselabs.com'
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_funcaptcha_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ async def solve_captcha():
'uri': 'login:password@123.123.123.123:8080'
})
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_geetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ async def solve_captcha():
url='https://2captcha.com/demo/geetest'
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_geetest_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ async def solve_captcha():
# }
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/async/async_geetest_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ async def solve_captcha():
url='https://2captcha.com/demo/geetest-v4'
)
except Exception as e:
print(e)
return e
sys.exit(e)


if __name__ == '__main__':
Expand Down
Loading