Issue
i keep getting an exception in this function when it trys to subscript the json object from the anticaptcha function, but all the other functions seem to be working fine
'email':email, 'username': username, 'password': passwd, 'invite': None, 'captcha_key': await anticaptcha.solve(session, 'register')['solution']['gRecaptchaResponse']
TypeError: 'coroutine' object is not subscriptable
-
async def register(session, username, email, passwd):
"""
sends a request to create an account
"""
async with session.post('http://randomsite.com',
headers={
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0'
},
json={
'email':email, 'username': username, 'password': passwd, 'invite': None, 'captcha_key': await anticaptcha.solve(session, 'register')['solution']['gRecaptchaResponse']
}) as response:
return await response.json()
the functions from the anticaptcha file
async def task_result(session, task_id):
"""
sends a request to return a specified captcha task result
"""
while True:
async with session.post('https://api.anti-captcha.com/getTaskResult',
json={
"clientKey": ANTICAPTCHA_KEY,
"taskId": task_id
}) as response:
result = await response.json()
if result['errorId'] > 0:
print(colored('Anti-captcha error: ' + result['statusCode']), 'red')
else:
if result['status'] == 'ready':
return await result
async def solve(session, url):
await get_balance(session)
task_id = await create_task(session, url)['taskId']
return await task_result(session, task_id)
Solution
await anticaptcha.solve(session, 'register')['solution']['gRecaptchaResponse']
means
await (anticaptcha.solve(session, 'register')['solution']['gRecaptchaResponse'])
but you want
(await anticaptcha.solve(session, 'register'))['solution']['gRecaptchaResponse']
If the other similar thing, task_id = await create_task(session, url)['taskId']
, is working, it probably doesn’t return a future and you can just set
task = create_task(session, url)['taskId']
without await
.
Answered By - Ry-
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.