当前位置:网站首页>The seventh topic of ape Anthropology
The seventh topic of ape Anthropology
2022-07-24 12:36:00 【consult one's pillow】
This question is a font mapping
You need to install this library to parse font files
from fontTools.ttLib import TTFont
Although every request will update the font file , But through observation , The coordinates of the font file will not change each time . So we get one ttf file , Just map locally
The font file is responding woff: "AAEAAAAKAIAAAwAgT1MvMgTkZQcAAAEoAAA here , This is a base64 String .base64 It's a thing that turns binary into string . Here, just reverse the solution directly .
Create mapping table python Code
# Read the local file and create a mapping table
def creat_map(temp_path):
# Returned mapping list 、
response_map = {
}
font_map = {
}
# Load font file :
font1 = TTFont('test1.ttf')
# obtain getGlyphOrder Node name value , Return to list
font_map[str(font1['glyf']['unib482'].flags)] = 0
font_map[str(font1['glyf']['unic462'].flags)] = 1
font_map[str(font1['glyf']['unie516'].flags)] = 2
font_map[str(font1['glyf']['unif157'].flags)] = 3
font_map[str(font1['glyf']['unif457'].flags)] = 4
font_map[str(font1['glyf']['unib215'].flags)] = 5
font_map[str(font1['glyf']['unie798'].flags)] = 6
font_map[str(font1['glyf']['unif491'].flags)] = 7
font_map[str(font1['glyf']['unie745'].flags)] = 8
font_map[str(font1['glyf']['unic894'].flags)] = 9
# print(font_map)
font2 = TTFont(temp_path)
# Get all names
full_name = font2.getGlyphNames()
for name in full_name:
if name != '.notdef':
# Get the coordinates of this font
bytearray_temp = str(font2['glyf'][name].flags)
# Get the number of this font mapping
response_map[name.replace('uni', '&#x')] = font_map[bytearray_temp]
return response_map
Logic code
headers = {
'authority': 'match.yuanrenxue.com',
'accept': 'application/json, text/javascript, */*; q=0.01',
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
'cache-control': 'no-cache',
'cookie': 'Hm_lvt_c99546cf032aaa5a679230de9a95c7db=1658124371,1658194036,1658281030,1658368336; no-alert3=true; tk=4032565147326549623; sessionid=2hvat8s8c5iunzne5x0mzd10u4ku7x2x; Hm_lvt_9bcbda9cbf86757998a2339a0437208e=1658124374,1658194060,1658281037,1658368358; Hm_lpvt_9bcbda9cbf86757998a2339a0437208e=1658387284; Hm_lpvt_c99546cf032aaa5a679230de9a95c7db=1658387288',
'pragma': 'no-cache',
'referer': 'https://match.yuanrenxue.com/match/7',
'sec-ch-ua': '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'yuanrenxue.project',
'x-requested-with': 'XMLHttpRequest',
}
calculator_score = 0
calculator_name = ""
for page in range(1, 6):
params = (
('page', page),
)
response = requests.get('https://match.yuanrenxue.com/api/match/7', headers=headers, params=params)
data = response.json()
data['parse_data'] = []
woff = data.get('woff')
with open('temp.ttf', 'wb') as f:
f.write(base64.b64decode(woff))
response_data = creat_map(temp_path='temp.ttf')
yyq = 1
for i in data.get('data'):
temp = ''
val = i.get('value').split(' ')
for j in val:
if j:
temp += str(response_data[j])
append_data = {
'value': int(temp), 'name': name[yyq + (page - 1) * 10]}
if append_data.get('value') > calculator_score:
calculator_score = append_data.get('value')
calculator_name = append_data.get('name')
data['parse_data'].append(append_data)
yyq += 1
print(data['parse_data'])
print(calculator_score)
print(calculator_name)
边栏推荐
- 使用TypeFace设置TextView的文字字体
- 元宇宙更多的功能和作用在于对于传统生活方式和生产方式的深度改造
- [rust] what software should I use to develop rust? Recommended editors commonly used to support rust
- Most after analyze table in PostgreSQL_ common_ Why is the elems field not filled in?
- Oceanbase Database Setup Test
- QT | summary of the use of edit box
- TypeNameExtractor could not be found
- SQL multi condition query cannot be implemented
- C Advanced - data storage
- Wechat applet learning five page Jump methods
猜你喜欢

基于Qt的软件框架设计

使用TypeFace设置TextView的文字字体

Everything about native crash

Leetcode:51. queen n

QT notes - custom data types

Implementing deep learning framework from zero -- further exploration of the implementation of multilayer bidirectional RNN

QT notes - realize form adaptation

ASP. Net core deployment Manual: 1. Deployment Basics

Examples of map search

QT based software framework design
随机推荐
计算两个坐标经纬度之间的距离(5种方式)
向勒索病毒说不,是时候重塑数据保护策略
Wechat applet - drawing dashboard
leetcode-81. 搜索旋转排序数组 II(二分查找返回true/false)
Seckill implementation diagram
以Chef和Ansible为例快速入门服务器配置
Buckle exercise - 32 divided into k equal subsets
Reserved instances & Savings Plans
SQL multi condition query cannot be implemented
Basic SQL server operation problems - only when lists are used and identity_ Only when insert is on can the display value be set for the identification column in the table
String matching KMP
基于ARM和FPGA的数字示波器设计——QMJ
QT notes - EventFilter event filter
The biggest crisis for testers in the workplace is not at the age of 30, but being laid off in middle age
QT notes - qtablewidget table spanning tree, qtreewidget tree node generates table content
Implementing deep learning framework from zero -- further exploration of the implementation of multilayer bidirectional RNN
Is it safe to contact the account manager online to open a fund account?
Using huggingface model to translate English
[rust] rust language foundation | you should quickly get an impression when learning a language
字符串匹配的KMP