1. 作者介紹
孟莉蘋,女,西安工程大學電子信息學院,2021級碩士研究生,張宏偉人工智能課題組
研究方向:機器視覺與人工智能
電子郵件:2425613875@qq.com
2. 身份證識別介紹
憑借領先的人工智能與知識圖譜技術(shù),對身份證正反面自動識別,并提取姓名、出生日期、身份證號、住址、性別、民族、發(fā)證機關等身份證實體信息。
3. 調(diào)用阿里智能云API
步驟一 :瀏覽器搜索阿里云,使用支付寶或者其他阿里APP掃碼后用手機驗證碼登陸。
步驟二:登錄后找到身份證識別OCR產(chǎn)品,并購買
步驟三:購買成功后點擊管理控制臺
步驟四:查看到身份證識別的AppCode等信息
步驟五:查看Python實現(xiàn)代碼,并將代碼中的appcode更換為自己的appcode
步驟六:查看請求參數(shù),調(diào)用該API需要在代碼中提供身份證號和姓名,無需上傳身份證圖片
步驟七:運行代碼后,返回值有實名認證是否通過、身份證號、姓名、家庭住址及出生日期等
4. 代碼解析
4.1 完整代碼
# coding=UTF-8
import requests
host = 'https://idcert.market.alicloudapi.com'
path = '/idcard'
method = 'GET'
appcode = '你自己的AppCode'#開通服務后 買家中心-查看AppCode
querys = 'idCard=511126******064713&name=楊過'
bodys = {}
url = host + path + '?' + querys
header = {"Authorization":'APPCODE ' + appcode}
try:
res = requests.get(url,headers=header)
except :
print("URL錯誤")
exit()
httpStatusCode = res.status_code
if(httpStatusCode == 200):
print("正常請求計費(其他均不計費)")
print(res.text)
else:
httpReason = res.headers['X-Ca-Error-Message']
if(httpStatusCode == 400 and httpReason == 'Invalid Param Location'):
print("參數(shù)錯誤")
elif(httpStatusCode == 400 and httpReason == 'Invalid AppCode'):
print("AppCode錯誤")
elif(httpStatusCode == 400 and httpReason == 'Invalid Url'):
print("請求的 Method、Path 或者環(huán)境錯誤")
elif(httpStatusCode == 403 and httpReason == 'Unauthorized'):
print("服務未被授權(quán)(或URL和Path不正確)")
elif(httpStatusCode == 403 and httpReason == 'Quota Exhausted'):
print("套餐包次數(shù)用完")
elif(httpStatusCode == 403 and httpReason == 'Api Market Subscription quota exhausted'):
print("套餐包次數(shù)用完,請續(xù)購套餐")
elif(httpStatusCode == 500 ):
print("API網(wǎng)關錯誤")
else:
print("參數(shù)名錯誤 或 其他錯誤")
print(httpStatusCode)
print(httpReason)
4.2 實驗結(jié)果
文章來源:http://www.zghlxwxcb.cn/news/detail-780910.html
參考
1.直接跳轉(zhuǎn)購買阿里云的身份證識別OCR鏈接:
https://market.aliyun.com/products/57000002/cmapi022049.html?spm=5176.shop.result.7.41a272026nu6Gi&innerSource=search#sku=yuncode1604900000文章來源地址http://www.zghlxwxcb.cn/news/detail-780910.html
到了這里,關于Python使用阿里API進行身份證實名認證的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!