M
M
molodoy_arsen2021-06-15 01:17:11
Python
molodoy_arsen, 2021-06-15 01:17:11

How to read captcha from a link?

There is a service for solving captchas, rucaptcha, I use it to solve simple pictures, the method works fine if you specify the path to the picture on the computer. You can somehow implement solving by link to the picture without downloading it to your PC. Here is the code:

import sys
import os
import twocaptcha

sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))


api_key = os.getenv('APIKEY_2CAPTCHA', 'API')

solver = twocaptcha.TwoCaptcha(api_key)
url = 'https://www.impex-jp.com/zip/part-search/check.html?v=60c7c9a0c71a0'

try:
    result = solver.normal(url)
    print(result)

except Exception as e:
    sys.exit(e)

else:
    sys.exit('solved: ' + str(result))

file not found error

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stefan, 2021-06-15
@molodoy_arsen

You download the image through some kind of requests, encode it in base64, and paste it. In your example, something like:

import sys
import os
import twocaptcha
import base64
import requests

sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))

def get_as_base64(url):
    return base64.b64encode(requests.get(url).content).decode('utf-8')

api_key = os.getenv('APIKEY_2CAPTCHA', 'API')

solver = twocaptcha.TwoCaptcha(api_key)
url = 'https://www.impex-jp.com/zip/part-search/check.html?v=60c7c9a0c71a0'

try:
    result = solver.normal(get_as_base64(url))
    print(result)

except Exception as e:
    sys.exit(e)

else:
    sys.exit('solved: ' + str(result))

U
Uno, 2021-06-15
@Noizefan

The most important question that you should ask yourself and your hand is - is recognition by reference supported?
I recommend not to ignore the documentation for the API
, otherwise the solution is the solution from Stefan

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question