#导入模块 |
import urllib.request |
import base64 |
from aip import AipOcr |
#获取浙江云平台登陆验证码 |
re = urllib.request.Request( "http://yun.zjer.cn/index.php?r=portal/Vcode/GetNewCode" ) |
html = urllib.request.urlopen(re) |
html = html.read().decode( "utf-8" ) |
#eval转化字符串到字典格式 |
html = eval (html) |
imgcode = html[ "imageinfo" ].replace( 'http:\\/\\/yun.zjer.cn\\/imgcode.php?d=' ,'') |
#unquote进行URL解码 |
imgcode = urllib.request.unquote(imgcode) |
#转化为base64图片编码 |
imgdata = base64.b64decode(imgcode) |
""" 你的 APPID AK SK """ |
APP_ID = '你的ID' |
API_KEY = '你的KEY' |
SECRET_KEY = '你的SECRET_KEY' |
client = AipOcr(APP_ID, API_KEY, SECRET_KEY) |
""" 如果有可选参数 """ |
options = {} |
options[ "language_type" ] = "CHN_ENG" |
options[ "detect_direction" ] = "true" |
options[ "detect_language" ] = "true" |
options[ "probability" ] = "true" |
#调用百度云文字识别接口,返回字典数据 |
client.basicGeneral(imgdata, options) |
by: 发表于:2018-05-31 10:59:04 顶(0) | 踩(0) 回复
??
回复评论