Python爬虫之验证码识别
2023-06-13 09:11:19 时间
Python爬虫之验证码识别
#识别车牌号
from aip import AipOcr
import re
APP_ID = '15469265'
API_KEY = 'rAGFtOChXtO7mnRPiwXg1Frf'
SECRET_KEY = 'Ailvoijh4X7lQIAoZ58UsGPlaDCmLIt7'
client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
""" 读取图片 """
def get_file_content(filePath):
with open(filePath, 'rb') as fp:
return fp.read()
image = get_file_content(r'C:\Users\Administrator\Desktop\img\ee.jpg')
""" 调用通用文字识别, 图片参数为本地图片 """
data=str(client.basicGeneral(image)).replace(' ','')
pat=re.compile(r"{'words':'(.*?)'}")
result=pat.findall(data)[0]
print(result)
#人工智能接口申请
from aip import AipOcr
import re
APP_ID="15725370"
API_KEY="t85bppstXXudNNSU0klALWgj"
SECRET_KEY="Zt7z61AXutINgWS1lqWe3xsWp9uePSFF"
client=AipOcr(APP_ID,API_KEY,SECRET_KEY)
with open(r"C:\Users\Administrator\Desktop\img\ee.jpg","rb") as f:
image=f.read()
data=str(client.basicGeneral(image)).replace(" ","")
pat=re.compile(r"{'words':'(.*?)'}")
result=pat.findall(data)[0]
print(result)
#文字识别
from aip import AipOcr
import re
import requests
APP_ID="15725370"
API_KEY="t85bppstXXudNNSU0klALWgj"
SECRET_KEY="Zt7z61AXutINgWS1lqWe3xsWp9uePSFF"
client=AipOcr(APP_ID,API_KEY,SECRET_KEY)
data=requests.get(r"http://127.0.0.1:8020/登陆验证码/login.html").text
pat=re.compile(r'<img src="(.*?)" style')
url="http://127.0.0.1:8020/登陆验证码/"+pat.findall(data)[0]
image=requests.get(url).content
data=str(client.basicGeneral(image)).replace(" ","")
pat=re.compile(r"{'words':'(.*?)'}")
result=pat.findall(data)[0]
print(result)
#模拟验证码识别
from aip import AipOcr
import re
import requests
APP_ID="15725370"
API_KEY="t85bppstXXudNNSU0klALWgj"
SECRET_KEY="Zt7z61AXutINgWS1lqWe3xsWp9uePSFF"
client=AipOcr(APP_ID,API_KEY,SECRET_KEY)
data=requests.get(r"http://127.0.0.1:8020/登陆验证码/login.html").text
pat=re.compile(r'<img src="(.*?)" style')
url="http://127.0.0.1:8020/登陆验证码/"+pat.findall(data)[0]
image=requests.get(url).content
data=str(client.basicGeneral(image)).replace(" ","")
pat=re.compile(r"{'words':'(.*?)'}")
result=pat.findall(data)[0]
print(result)
相关文章
- java浅拷贝和深拷贝的区别_python的浅拷贝和深拷贝
- python中pygame怎么安_Python中pygame安装方法图文详解
- python删除首行_Python删除文件第一行
- python—pyquery
- 简述python变量的命名规则_Python 变量命名规则
- unboundlocalerror python_Python问题:UnboundLocalError: local variable ‘xxx’ referenced before assignme
- python基础(3)列表list[通俗易懂]
- python读paper
- Python数组切片_python print数组
- Python udp编程_python socket udp
- python_sklearn库的使用
- Python爬虫技术系列-05字符验证码识别
- Python写个“点球大战”小游戏
- 【错误记录】Mac 中 Python 报错 ( ERROR: Could not build wheels for numpy which use PEP 517 | 问题未解决 | 问题记录 )
- python-数据库编程-如何在Python中连接到数据库
- python通过MySQLdb访问mysql数据库详解编程语言
- Python常用的第三方模块——学习笔记详解编程语言
- Linux中运行Python文件的步骤(linux运行python文件)
- Python驱动Oracle数据库(python操作oracle)
- 使用Python连接SQL Server数据库(python连接sqlserver数据库)
- Python编程连接MySQL:从零开始(python与mysql)
- Linux下的Python开发技术之旅(linux下python开发)
- Python运行的17个时新手常见错误小结
- Python使用MySQLdbforPython操作数据库教程
- Python使用py2exe打包程序介绍
- python执行shell获取硬件参数写入mysql的方法