栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python 文本混淆绕过 获取图片文字

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python 文本混淆绕过 获取图片文字

python 文本混淆绕过 获取图片文字

import io
import requests
from urllib.parse import urljoin
from parsel import Selector
try:
 from PIL import Image
except ImportError:
 import Image
import pytesseract
url = 'http://xxxx/hello.png'
resp = requests.get(url)
sel = Selector(resp.text)
# 从响应正文中提取图片名称
image_name = sel.css('.pn::attr("src")').extract_first()
# 拼接图片名和URL
image_url = urljoin(url, image_name)
# 请求图片,拿到图片的字节流内容
image_body = requests.get(image_url).content
# 使用Image.open打开图片字节流,得到图片对象
image_stream = Image.open(io.BytesIO(image_body))
print(image_stream)
# 使用光学字符识别从图片对象中读取文字并打印输出结果
# code =pytesseract.image_to_string(image_stream,lang="eng")
code =pytesseract.image_to_string(image_stream,lang="chi_sim")
print(code)


#coding:gbk
# import pytesseract  
# from PIL import Image
 
 
# # 使用pytesseract对英文进行识别,lang参数可省略
# code = pytesseract.image_to_string(Image.open(r'code.png'),lang="eng")
# print(code)
# # 使用pytesseract对中文(含英文,但识别率降低)进行识别
# code = pytesseract.image_to_string(Image.open(r'code.jpg'),lang='chi_sim')
# print(code)
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1008482.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号