Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #..
- # wait a few seconds
- time.sleep(10)
- # Query 2captcha for the solution with automatic retries
- max_retries = 10 # Maximum number of retries
- solution = ''
- print('Querying for solution...')
- for retry_count in range(max_retries):
- time.sleep(5) # Wait for 5 seconds before querying again
- print(f'Retry {retry_count + 1}...')
- # make GET request
- response = requests.get(f'http://2captcha.com/res.php?key={api_key}&action=get&id={captcha_id}&json=1')
- # retrieve response
- response_data = response.json()
- solution = response_data.get('request', '')
- if solution != 'CAPCHA_NOT_READY': # If solution is obtained, break out of the loop
- break
- if solution == 'CAPCHA_NOT_READY':
- print('Maximum retries reached. CAPTCHA solution not obtained.')
- else:
- print('Solution:', solution)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement