代码
import sys sys.path.append(".") import base64 import requests with open("ocr/文字验证码/8we1.png", 'rb') as f: image = f.read() image = base64.b64encode(image) image = str(image, 'utf8') data = { "clientKey":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "task": { "type": "ImageToTextTaskTest", "body": image # base64编码后的图片 } } r = requests.post("https://api.yescaptcha.com/createTask", json=data).json() print(r)
输出
{'errorId': 0, 'errorCode': '', 'status': 'ready', 'solution': {'text': '8we1'}, 'taskId': '1fb204c2-d8d7-11ec-9dc6-8a3e9a7e9eea'}