当前位置:网站首页>[font anti crawl] cat x-eye Yingshi, we're bullying you again, using OCR recognition technology
[font anti crawl] cat x-eye Yingshi, we're bullying you again, using OCR recognition technology
2022-07-21 09:29:00 【InfoQ】
️ Python Anti climbing actual combat scene

Element
mtsi-font

@font-face{font-family: "mtsi-font";src:url("//s3plus.meituan.net/v1/mss_73a511b8f91f43d0bdae92584ea6330b/font/e5389ac6.eot");src:url("//s3plus.meituan.net/v1/mss_73a511b8f91f43d0bdae92584ea6330b/font/e5389ac6.eot?#iefix") format("embedded-opentype"),url("//s3plus.meituan.net/v1/mss_73a511b8f91f43d0bdae92584ea6330b/font/e5389ac6.woff");}
.stonefont {
font-family: mtsi-font;
}
.eot
.woff
.woff
FontCreator


<span class="stonefont">.</span>

uniE36C

uniE36C
fontTools
pip install fontTools -i https://pypi.tuna.tsinghua.edu.cn/simple
from fontTools.ttLib import TTFont
TTFont('03337c30.woff').saveXML('font1.xml')
TTFont('e5389ac6.woff').saveXML('font2.xml')



font_dict = {
'uniE415': '3',
'uniF41A': '8',
'uniF078': '7',
'uniE5BF': '0',
'uniE36C': '9',
'uniF8DF': '1',
'uniE5A5': '6',
'uniEF4D': '4',
'uniE6E0': '2',
'uniED3D': '5',
}
from fontTools.ttLib import TTFont
base_font = TTFont('03337c30.woff')
print(base_font)
base_list = base_font.getGlyphOrder()[2:]
print(base_list)
# Suppose the score string captured is as follows
# 
font_str = ''
font_list = font_str.split(';')[:-1]
font_list = ['uni' + _[3:].upper() for _ in font_list]
font_dict = {
'uniE415': '3',
'uniF41A': '8',
'uniF078': '7',
'uniE5BF': '0',
'uniE36C': '9',
'uniF8DF': '1',
'uniE5A5': '6',
'uniEF4D': '4',
'uniE6E0': '2',
'uniED3D': '5',
}
real_numm = [font_dict[f] for f in font_list]
print(real_numm)
['2', '0', '3', '7', '7']
️ Actual combat scene of digital recognition
woff
ttf
from fontTools.ttLib import TTFont
from fontTools.ttLib.woff2 import decompress
# Font files downloaded from the target site
woff_path = "./03337c30.woff"
# ttf Format file
ttf_path = './font.ttf'
# take woff Document conversion ttf file
decompress(woff_path, ttf_path)
font = TTFont(ttf_path)
print(font)

# Picture width and height
img_size = 512
# Instantiate an image object
img = Image.new('1', (img_size, img_size), 255)
# Drawing pictures
draw = ImageDraw.Draw(img)
img.show()
font = TTFont('./font.ttf')
for cmap_code, glyph_name in font.getBestCmap().items():
print(cmap_code,glyph_name)
120 x
58220 uniE36C
58389 uniE415
58789 uniE5A5
58815 uniE5BF
59104 uniE6E0
60733 uniED3D
61261 uniEF4D
61560 uniF078
62490 uniF41A
63711 uniF8DF
uni
from fontTools.ttLib import TTFont
from fontTools.ttLib.woff2 import decompress
from PIL import ImageFont, Image, ImageDraw
# Picture width and height
img_size = 512
font = TTFont('./font.ttf')
font_img = ImageFont.truetype('./font.ttf', img_size)
for cmap_code, glyph_name in font.getBestCmap().items():
# print(cmap_code,glyph_name)
# Instantiate an image object
img = Image.new('1', (img_size, img_size), 255)
# Drawing pictures
draw = ImageDraw.Draw(img)
# Read the encoding into bytes
txt = chr(cmap_code)
x, y = draw.textsize(txt, font=font_img)
draw.text(((img_size - x) // 2, (img_size - y) // 2), txt, font=font_img, fill=0)
img.show()
ddddocr
bytes_io = BytesIO()
img.save(bytes_io, format="PNG")
word = ocr.classification(bytes_io.getvalue()) # Identify Fonts
print(word)
from fontTools.ttLib import TTFont
from fontTools.ttLib.woff2 import decompress
from PIL import ImageFont, Image, ImageDraw
from io import BytesIO
import ddddocr
"""
# Font files downloaded from the target site
woff_path = "./03337c30.woff"
# ttf Format file
ttf_path = './font.ttf'
# take woff Document conversion ttf file
decompress(woff_path, ttf_path)
font = TTFont(ttf_path)
"""
# Picture width and height
img_size = 512
font = TTFont('./font.ttf')
font_img = ImageFont.truetype('./font.ttf', img_size)
ocr = ddddocr.DdddOcr()
for cmap_code, glyph_name in font.getBestCmap().items():
# print(cmap_code,glyph_name)
# Instantiate an image object
img = Image.new('1', (img_size, img_size), 255)
# Drawing pictures
draw = ImageDraw.Draw(img)
# Read the encoding into bytes
txt = chr(cmap_code)
x, y = draw.textsize(txt, font=font_img)
draw.text(((img_size - x) // 2, (img_size - y) // 2), txt, font=font_img, fill=0)
bytes_io = BytesIO()
img.save(bytes_io, format="PNG")
word = ocr.classification(bytes_io.getvalue()) # Identify Fonts
print(cmap_code, glyph_name, word)
2 extra bytes in post.stringData array
120 x
58220 uniE36C 9
58389 uniE415 3
58789 uniE5A5 6
58815 uniE5BF 0
59104 uniE6E0 2
60733 uniED3D 5
61261 uniEF4D 4
61560 uniF078 7
62490 uniF41A 8
63711 uniF8DF 1

uni code

边栏推荐
- 一个换行符引发的思考!
- Unity3D不同脚本函数或参数之间调用
- Principle analysis of SAP Spartacus reading cart
- Draw a callout box according to Yolo TXT label data
- Why does cloud speed live broadcast win the favor of enterprises?
- ESP32 OLED LVGL 显示常用中文字符
- 2022第十四届南京国际智慧工地展览会|智慧工地展
- 游戏合作伙伴专题:BreederDAO 与 MonkeyLeague 的合作拉开序幕
- MySQL explicit lock
- Access SAP Hana cloud instance in SAP Business Application studio
猜你喜欢
随机推荐
How to use node JS access data in SAP Hana cloud database
Food in dog days
iOS_ Calculate cache file size and clear cache
MySQL全局锁
【性能优化】MySQL常用慢查询分析工具
Why does cloud speed live broadcast win the favor of enterprises?
Unity Panel 控件
高并发的深入理解
Record locks
Codeforces Round #649 (Div. 2)ABC题解
rank函数的功能有哪些
理财产品到期了,收益是怎么算的?
MySQL pessimistic lock
使用 SAP UI5 系统测试工具 UIVeri5 的一个具体例子
SAP Spartacus 读取 Cart 的原理分析
WireShark 简介和抓包原理及过程
A specific example of using SAP ui5 system testing tool uiveri5
SAP Hana cloud tutorial 2: how to insert data into the database table of Hana cloud instance on SAP BTP
Mysql 系列 | 日志模块
(homework) C language questions: structural alignment number, bit segment, Consortium