Python:验证码识别
说明:此验证方法很弱,几乎无法识别出正确的验证码 🤦♀️
1. 安装 PIL
2. 安装 tesseract(mac)
brew install tesseract
报错:
touch: /usr/local/Homebrew/.git/FETCH_HEAD: Permission denied fatal: Unable to create '/usr/local/Homebrew/.git/index.lock': Permission denied error: could not lock config file .git/config: Permission denied
解决方案:
sudo chown -R $(whoami) /usr/local
3. 安装 pytesseract
pip install pytesseract
4. 代码
import pytesseract from PIL import Image image = Image.open("vcode/kfok.png") vcode = pytesseract.image_to_string(image) print(vcode)
参考:
https://www.cnblogs.com/yeayee/p/4955506.html