通过百度云获得图片验证码
#!/usr/bin/env python # -*- coding:utf-8 -*- # @Time:2022/05/16 10:21 # @Author:Hero # @File:VerCodeFromBaidu.py # @Sofeware :PyCharm ''' 通过百度云 获得 图片验证码 ''' import os from aip import AipOcr class getwords(): def __init__(self, filePath): super(getwords, self).__init__() self.__filePath = filePath def get_file_content(self, filePath): with open(filePath, "rb") as fp: return fp.read() def getwords(self): """ 你的 APPID AK SK APP_ID = '你的 App ID' API_KEY = '你的 Api Key' SECRET_KEY = '你的 Secret Key' """ APP_ID = '26238932' API_KEY = 'MdA7GCAME5AO9sTaPDU0ZuhI' SECRET_KEY = 'Your key of baidu' client = AipOcr(APP_ID, API_KEY, SECRET_KEY) image = self.get_file_content(self.__filePath) # url = "https://www.x.com/sample.jpg" # pdf_file = get_file_content('文件路径') # 调用通用文字识别(标准版) res_image = client.basicGeneral(image) # res_url = client.basicGeneralUrl(url) # res_pdf = client.basicGeneralPdf(pdf_file) # print(res_image['words_result'][0]['words']) # return res_image['words_result'][0]['words'] return res_image if __name__ == '__main__': # t = getwords(os.path.join(os.getcwd(), "imgVeriCode.png")) t = getwords("e://fms2022/imgVeriCode.png") wd = t.getwords() print(wd) print(wd['words_result'][0]['words'])
合集:
python
分类:
编程相关 / Python
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了