最近有打码需求,选择的若快,以下是通过python调用api来实现若快打码接口调用。
# encoding=utf8 import requests import time def get_verify_code(im, typeid): verify_code = '' url = 'http://api.ruokuai.com/create.json' params = { 'typeid': typeid, 'timeout': 60, 'username': '', # 用户名 'password': '', # 密码 'softid': '', # 软件Id 'softkey': '' # 软件Key } files = { 'image': ('a.jpg', im) } headers = { 'Connection': 'Keep-Alive', 'Expect': '100-continue', 'User-Agent': 'ben' } try: resp = requests.post(url, data=params, files=files, headers=headers) except Exception as e: print 'get_verify_code error: ', e return verify_code try: verify_code = resp.json().get('Result', '') except Exception as e: print 'get_verify_code failed: ', e return verify_code if not verify_code: try: print resp.text except: print 'verify code resp is None' return verify_code def main(): path = '' # 图片路径 with open(path, 'rb') as f: content = f.read() vcode = get_verify_code(content, 3040) print '--- vcode: ', vcode if __name__ == '__main__': main()
讯享网
说明:

另外,上面代码中get_verify_code的第一个参数im既可以是以二进制保存的图片,也可以是通过http请求得到的图片的二进制源码,像这样:
讯享网def main(): url = '' # 请求图片的链接 resp = requests.get(url) content = resp.content vcode = get_verify_code(content, 3040) print '--- vcode: ', vcode if __name__ == '__main__': main()
最后,代码中的3040是官方“编码Typeid”中的一种,具体可以参考这里:价格类型

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/37367.html