先看截图,有框框:
我们就来破了他,上来我们先看是静态还是动态,我们重新加载下,发现是静态的,我们的我就用我们的老套路破了它
import requests
from fontTools.ttLib import TTFont
url = 'https://book.qidian.com/info/1021617576'
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36',
}
page_text = requests.get(url=url,headers=headers).text
接下里我们要字体文件
这个字体文件就是一个文件链接,用着这提取链接,我么直接请求他,保存下来就好了
font_link = re.findall(r"format\('eot'\); src: url\('(.*?)'\) format\('woff'\)",page_text)[0]
res = requests.get(url=font_link).content
with open('1.woff','wb') as f:
f.write(res)
我们还是用python的TTFont解析字体,解析成我们能看懂的xml格式
font = TTFont('1.woff')
font.saveXML('1.xml')
font_map = font['cmap'].getBestCmap()
我们看xml文件的cmap部分,构建映射关系
font_dict = {'eight':8, 'two':2, 'six':6, 'three':3, 'nine':9, 'zero':0, 'four':4, 'seven':7, 'five':5, 'period':".",'one':1}
我们要将映射换关系的key替换过来,替换成{100134: 0, 100136: 7, 100137: 4, 100138: 2, 100139: 1, 100140: 5, 100141: 8, 100142: 3, 100143: 6, 100144: ‘.’, 100145: 9}
for key in font_map:
font_map[key] = font_dict[font_map[key]]
print(font_map)
我们还是遍历映射关系,将key替换成&#+key+‘;’
for key in font_map:
page_text = page_text.replace('&#' + str(key) + ';', str(font_map[key]))
print(page_text)
循环这个字典替换成所对应的值:
# !/usr/bin python3
# encoding : utf-8 -*-
# @software : PyCharm
# @file : 起点中文网字体解密.py
# @Time : 2021/6/16 15:16
import re
import requests
from fontTools.ttLib import TTFont
url = 'https://book.qidian.com/info/1021617576'
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36',
}
page_text = requests.get(url=url,headers=headers).text
font_link = re.findall(r"format\('eot'\); src: url\('(.*?)'\) format\('woff'\)",page_text)[0]
res = requests.get(url=font_link).content
with open('1.woff','wb') as f:
f.write(res)
font = TTFont('1.woff')
font.saveXML('1.xml')
font_map = font['cmap'].getBestCmap()
print(font_map)
font_dict = {'eight':8, 'two':2, 'six':6, 'three':3, 'nine':9, 'zero':0, 'four':4, 'seven':7, 'five':5, 'period':".",'one':1}
for key in font_map:
font_map[key] = font_dict[font_map[key]]
print(font_map)
for key in font_map:
print('&#' + str(key) + ';')
page_text = page_text.replace('&#' + str(key) + ';', str(font_map[key]))
print(page_text)