猫眼电影网站,中电影评分在网页显示正常但是检查网页源码会发现,评分所在位置是一串迷之字符串根本认不出,原因是使用了自定义字体代码
<span class="stonefont">.</span>
使用了自定义的stonefont字体,我们在网页中查找stonefont,很快有了发现,这就是标准的@font-face定义方法。因此我们访问其中woff文件的地址,将woff字体文件下载到本地。我们需要将woff字体转换成otf字体。百度可以直接转换字体 ,地址:http://fontstore.baidu.com/static/editor/index.html
得到
我们可以看到该文件是无序的,所以我们要先以该文件排序,,按照顺序将字形保存在列表中,
font = TTFont('./fonts/9f1eed3c6cfa21fa95ee464955b750162088.woff') # 打开文件 uniList = font['cmap'].tables[0].ttFont.getGlyphOrder()#取出字形保存到uniList中 # print(font['glyf'][uniList[2]]) a = [] a.append(font['glyf'][uniList[4]])#0的字形在该uniList所在索引为4 a.append(font['glyf'][uniList[3]])#1的字形在该uniList所在索引为3 a.append(font['glyf'][uniList[6]]) a.append(font['glyf'][uniList[5]]) a.append(font['glyf'][uniList[7]]) a.append(font['glyf'][uniList[-1]]) a.append(font