forked from ZennoLab/capmonstercloud-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinance.py
More file actions
37 lines (31 loc) · 1.41 KB
/
Copy pathbinance.py
File metadata and controls
37 lines (31 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import time
import asyncio
from capmonstercloudclient.requests import BinanceTaskRequest
from capmonstercloudclient import ClientOptions, CapMonsterClient
async def solve_captcha_sync(num_requests):
return [await cap_monster_client.solve_captcha(binance_request) for _ in range(num_requests)]
async def solve_captcha_async(num_requests):
tasks = [asyncio.create_task(cap_monster_client.solve_captcha(binance_request))
for _ in range(num_requests)]
return await asyncio.gather(*tasks, return_exceptions=True)
if __name__ == '__main__':
key = os.getenv('API_KEY')
client_options = ClientOptions(api_key=key)
cap_monster_client = CapMonsterClient(options=client_options)
binance_request = BinanceTaskRequest(
websiteUrl='https://accounts.binance.com/ru/login?loginChannel=&return_to=',
websiteKey='login',
validateId="2b8137c0b9b44189800368819354e114"
)
nums = 3
# Sync test
sync_start = time.time()
sync_responses = asyncio.run(solve_captcha_sync(nums))
print(f'average execution time sync {1/((time.time()-sync_start)/nums):0.2f} ' \
f'resp/sec\nsolution: {sync_responses[0]}')
# Async test
async_start = time.time()
async_responses = asyncio.run(solve_captcha_async(nums))
print(f'average execution time async {1/((time.time()-async_start)/nums):0.2f} ' \
f'resp/sec\nsolution: {async_responses[0]}')