Advertisement
dereksir

Untitled

Feb 13th, 2024 (edited)
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. #..
  2.     # wait a few seconds
  3.     time.sleep(10)
  4.    
  5.     # Query 2captcha for the solution with automatic retries
  6.     max_retries = 10  # Maximum number of retries
  7.     solution = ''
  8.     print('Querying for solution...')
  9.     for retry_count in range(max_retries):
  10.         time.sleep(5)  # Wait for 5 seconds before querying again
  11.         print(f'Retry {retry_count + 1}...')
  12.         # make GET request
  13.         response = requests.get(f'http://2captcha.com/res.php?key={api_key}&action=get&id={captcha_id}&json=1')
  14.         # retrieve response
  15.         response_data = response.json()
  16.         solution = response_data.get('request', '')
  17.         if solution != 'CAPCHA_NOT_READY':  # If solution is obtained, break out of the loop
  18.             break
  19.  
  20.     if solution == 'CAPCHA_NOT_READY':
  21.         print('Maximum retries reached. CAPTCHA solution not obtained.')
  22.     else:
  23.         print('Solution:', solution)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement