python教程

python批量获取百度云用户份信息

我的站长站 2024-01-19 人阅读

python批量获取百度云用户份信息,未编译直接发代码,能用到的自行修改,以下代码适合于在文件夹中多个文件批量提取用户信息。

from aip import AipOcr
import os
import imghdr
import sys
#import filetype
 
 
#代{过}{滤}理服务器访问设置设置
#os.environ["http_proxy"] = "http://localhost:8888"
#os.environ["https_proxy"] = "http://localhost:8888"
 
 
#百度云账号,自己填写上自己的百度云开发帐号信息
APP_ID='99999999'
API_KEY='xxxxxxxxxxxxxxxxxxxxx'
SECRET_KEY='xxxxxxxxxxxxxxxxxxxxxx'
#调用百度云接口
client=AipOcr(APP_ID,API_KEY,SECRET_KEY)
def get_file_content(filePath):
    with open(filePath,'rb') as fp:
            return fp.read()
 
def duqusfzxx(imagefile):
    image=get_file_content(imagefile)
    #识别身份证正面
    idCardSide="front"
    #识别身份证背面
    #idCardSide="back"
    client.idcard(image,idCardSide)
    options={}
    options["detect_direction"]="true" #是否检测图像朝向,默认不检测
    options["detect_risk"]="false"  #是否开启身份证风险类型(身份证复印件)
    #带参数调用身份证识别
    result=client.idcard(image,idCardSide,options)
    #识别为一个list
    #    {'姓名': {'words': '奥巴马', 'location': {'top': 52, 'left': 61, 'width': 34, 'height': 17}}, '民族': {'words': '哈尼', 'location': {'top': 69, 'left': 137, 'width': 9, 'height': 14}}, '住址': {'words': '盛顿特区宜宾法尼亚大道1600号白官', 'location': {'top': 113, 'left': 70, 'width': 118, 'height': 49}}, '公民身份号码': {'words': '', 'location': {'top': 0, 'left': 0, 'width': 0, 'height': 0}}, '出生': {'words': '19610804', 'location': {'top': 90, 'left': 68, 'width': 101, 'height': 26}}, '性别': {'words': '男', 'location': {'top': 78, 'left': 65, 'width': 14, 'height': 15}}}
    id_msg=''
    if isinstance(result,dict):
        words=result['words_result']
        #print(words)
         
        #身份证用下面的两个
        #id_msg=words[u'姓名']['words']+'\t'+words[u'公民身份号码']['words']
        id_msg=words[u'姓名']['words']+'\t'+words[u'公民身份号码']['words']+'\t'+words[u'住址']['words']
         
        print(id_msg)
        #print(words[u'姓名']['words'])
        #print(words[u'公民身份号码']['words'])
         
        #以上内容 建议使用 姓名\t身份证号码方式显示
 
 
def bianli(rootDir):
    imgType_list={'jpg','bmp','png','jpeg','jfif'}
    for root,dirs,files in os.walk(rootDir):
        for file in files:
            filepath=os.path.join(root,file)
            #print(imghdr.what(file))
            #print(filetype.guess(filepath))                   
            try:
                #print(filetype.guess(filepath).mime)
                #f(imghdr.what(filepath) in imgType_list):
                f=filepath.rfind(('.'))
                if filepath[f+1:] in imgType_list:
                    duqusfzxx(filepath)                
            except:
                print(filepath+"\t 出错!")
 
 
 
#直接调用,修改一下文件夹即可,也可以写成参数格式,懒得修改了
bianli(r'D:\05.身份验证')


相关推荐
  • 百度云
  • 百度云网盘v5.6.0加速破解版
    百度云网盘v5.6.0加速破解版

    现在时间为2017年6月24日 15:43:32,经测试本破解版是可用的。现在的百度云网盘PC客户端越来越难破解了,本破解版也是测了N多版本中唯一有效,还在到处找破解版的朋友值得使用!本百度云网盘v5.6.0加速...

    软件分享 1567 6年前
  • 百度云盘下载器PanDownload
    百度云盘下载器PanDownload

    现在时间为2017年6月26日 20:27:45,经测本版本依然可以使用,需要下载的朋友赶快抓紧时间了。百度云盘下载器PanDownload使用说明:1、登录时提示“登录失败,请在弹出的窗口操作,或重新登录”。这个是因...

    软件分享 631 6年前
  • 百度云网盘9.6.3安卓破解版
    百度云网盘9.6.3安卓破解版

    百度云网盘解版截图百度云网盘安卓破解版说明尊享SVIP下载加速,拉黑号无效果去除视频15秒加载广告,秒播解除视频音频变速播放限制去除界面无用banner去除讨厌的小红点禁止检查更新...

    软件分享 470 5年前
最新更新