gpt4 book ai didi

python - Yodlee:无法在 getMFAResponseForSite 中将图像字节转换为验证码 - Python

转载 作者:太空宇宙 更新时间:2023-11-03 17:31:00 25 4
gpt4 key购买 nike

正如您在帖子中看到的(Java):

getMFAResponseForSite - rendering array as a captcha image

和 (C#)

Yodlee: Unable to convert image codes into captcha in getMFAResponseForSite(Captcha type) - C#

Yodlee API getMFAResponseForSite 使用包含 MFA 表单的 JSON 进行应答。在Python中,我正在尝试以下解决方案,但没有结果:

import array
import base64

img_array = [66, 77, -98, -19, 0, 0, 0, 0, 0, 0, 54, 0, 0, 0, 40,...]
new_img_array = []

for x in img_array:
new_img_array.append(abs(x))

img_byte_array = bytearray(new_img_array)
fh = open("path.jpg", "wb")
fh.write(img_byte_array)
fh.close()

我尝试直接转换字节数组,但它会抛出错误,因为字节值必须在 0-255 之间

希望有人知道如何解决这个问题

最佳答案

这里采取了许多额外的步骤,以及未使用的导入。另外,对我来说,返回的yodlee图像数据是windows bmp数据(不是jpg)。这是答案的本质:

with open('captcha.bmp', 'wb') as c:
write(''.join(map(lambda x: chr(x % 256), img_array)))

或者,按照链接帖子中的建议:

with open('captcha.bmp', 'wb') as c:
write(str(bytearray(map(lambda x: chr(x % 256), img_array))))

这直接作用于 getMFAResponseForSite 提供的 fieldInfo.image 数组。

关于python - Yodlee:无法在 getMFAResponseForSite 中将图像字节转换为验证码 - Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31861604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com