Last active
May 23, 2018 07:32
-
-
Save anuj9196/ea850c2238e7afa6bd72dbf76b0a089a to your computer and use it in GitHub Desktop.
captcha solving error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# my function to solve the captcha | |
# here I'm passing the url of the image with captcha_image | |
# the url example: https://images-na.ssl-images-amazon.com/captcha/sargzmyv/Captcha_xhoxwckkdo.jpg | |
``` | |
def solve_captcha(captcha_image): | |
print('--- called solve_captcha for captcha: '+str(captcha_image)) | |
print('--- setting Death By Captcha credentials---') | |
client = deathbycaptcha.SocketClient('vega6dev', 'dev@1234') | |
print('--- trying decode CAPTCHA---') | |
try: | |
balance = client.get_balance() | |
# Put your CAPTCHA file name or file-like object, and optional | |
# solving timeout (in seconds) here: | |
print('--- setting CAPTCHA image---') | |
captcha = client.decode(captcha_image, 20) | |
print('--- Death By Captcha executed... checking result---') | |
if captcha: | |
print('--- CAPTCHA solved---') | |
print('--- CAPTCHA: '+str(captcha["captcha"])) | |
print('--- CAPTCHA text: '+str(captcha["text"])) | |
# The CAPTCHA was solved; captcha["captcha"] item holds its | |
# numeric ID, and captcha["text"] item its text. | |
print("CAPTCHA %s solved: %s" % (captcha["captcha"], captcha["text"])) | |
return captcha["text"] | |
except deathbycaptcha.AccessDeniedException: | |
# Access to DBC API denied, check your | |
print("error: Access to DBC API denied, check your credentials and/or balance") | |
return None | |
``` | |
# Error log contains | |
``` | |
File "/home/amzitrage/app.amzitrage.com/scraper/utils.py", line 182, in amazon_upc_to_asin | |
captcha_string = solve_captcha(captcha_image) | |
File "/home/amzitrage/app.amzitrage.com/scraper/utils.py", line 366, in solve_captcha | |
balance = client.get_balance() | |
File "/home/amzitrage/app.amzitrage.com/dbc_api_python3/deathbycaptcha.py", line 159, in get_balance | |
return self.get_user().get('balance') | |
File "/home/amzitrage/app.amzitrage.com/dbc_api_python3/deathbycaptcha.py", line 421, in get_user | |
return self._call('user') or {'user': 0} | |
File "/home/amzitrage/app.amzitrage.com/dbc_api_python3/deathbycaptcha.py", line 373, in _call | |
self._call('login', self.userpwd.copy()) | |
File "/home/amzitrage/app.amzitrage.com/dbc_api_python3/deathbycaptcha.py", line 391, in _call | |
raise IOError('Connection lost timed out during API request') | |
OSError: Connection lost timed out during API request | |
``` | |
NOTE: I even tried downloading the image and passing the image path but got same error. | |
Error is occured on first call => balance = client.get_balance() | |
using Python: 3.6.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment