猿人学第七题-css加密
原地址:猿人学第七题
分析接口
接口很明显并无加密
分析数据
对比两张图,很明显data中就是胜点数据那么 woff字段就是这次要解决的字体文件
解析woff文件
先确定一下woff文件是否正确
将woff字段下载下来
放到 lconfont上验证一下
这时其实如果字符串不变的话 就可以手动复制写一个字典将这题解决了
但是后面发现这个值是每页不断变化的
所以 我们就需要用程序自动地去解决
代码解析woff文件
解决思路:
一、:读取woff文件
二、:将字体写入图片中
三、:识别图片
四、:返回对应键值对
读取woff文件
font = TTFont(fontPath) # 打开文件
codeList = font.getGlyphOrder()[1:]
创建图片
im = Image.new("RGB", (1800, 1000), (255, 255, 255))
dr = ImageDraw.Draw(im)
font = ImageFont.truetype(fontPath, 40)
将字体写入图片
count = 3
arrayList = numpy.array_split(codeList, count) #将列表切分成15份,以便于在图片上分行显示
# print(arrayList)
for t in range(count):
newList = [i.replace("uni", "\\u") for i in arrayList[t]]
text = "".join(newList)
text = text.encode('utf-8').decode('unicode_escape')
dr.text((0, 50 * t), text, font=font, fill="#000000")
im.save("sss.jpg")
识别图片
result = pytesseract.image_to_string(im, lang="chi_sim")
result = result.replace(" ", "").replace("\n", "")
codeList = [i.replace("uni", "&#x") for i in codeList]
return dict(zip(codeList, list(result)))
结果
全部代码-字体识别
def fontConvert(fontPath): #将web下载的字体文件解析,返回其编码和汉字的对应关系
font = TTFont(fontPath) # 打开文件
codeList = font.getGlyphOrder()[1:]
# print(codeList)
im = Image.new("RGB", (1800, 1000), (255, 255, 255))
dr = ImageDraw.Draw(im)
font = ImageFont.truetype(fontPath, 40)
count = 3
arrayList = numpy.array_split(codeList, count) #将列表切分成15份,以便于在图片上分行显示
# print(arrayList)
for t in range(count):
newList = [i.replace("uni", "\\u") for i in arrayList[t]]
text = "".join(newList)
text = text.encode('utf-8').decode('unicode_escape')
dr.text((0, 50 * t), text, font=font, fill="#000000")
im.save("sss.jpg")
# im = Image.open("sss.jpg") #可以将图片保存到本地,以便于手动打开图片查看
result = pytesseract.image_to_string(im, lang="chi_sim")
result = result.replace(" ", "").replace("\n", "")
codeList = [i.replace("uni", "&#x") for i in codeList]
return dict(zip(codeList, list(result)))
结尾
其实css加密这种解法大多一样 保存其woff文件 识别 得到键值对 替换
大众点评、猫眼电影 汽车之家都可用上方思路去解决