起点字体加密
536阅读 · 0评论 · 2020/05/22发布 前往评论
前言
该文章主要提供交流学习使用,请勿利用其进行不当行为!
如本篇文章侵犯了贵公司的隐私,请联系我立刻删除!
如因滥用解密技术而产生的风险与本人无关!
前段时间阅文的那个事情沸沸扬扬,好奇的又打开了起点中文网,发现起点对有多少推荐这些数据加密了,也不知道为什么这么做。
首先
通过万能F12看效果,因为过程流程,推断不是js加密。点一下,果然是字体加密,通过ttf文件。
qidian_url = 'https://book.qidian.com/info/1010868264' def get_font_res(qidian_url): resp = requests.get(qidian_url) font = TTFont(BytesIO(resp.content)) content = font.getBestCmap() font.close() return content
第二步
结合网页中的参数进行对比,将其替换
def get_encode(content, values): convert_dict = { 'one': '1', 'two': '2', 'three': '3', 'four': '4', 'five': '5', 'six': '6', 'seven': '7', 'eight': '8', 'nine': '9', 'period': '.', 'zero': '0' } key_count = '' for value in values.split(';'): if value: value = value[2:] key = content[int(value)] key_count += convert_dict[key] return key_count
第三步
结合前获取网页数据,进行解密
resp = requests.get(qidian_url) qidian_class = re.findall("https://qidian.gtimg.com/qd_anti_spider/(.{1,10})\.eot\?'\) format\('eot'\)", resp.text)[0] qidian_url = f'https://qidian.gtimg.com/qd_anti_spider/{qidian_class}.ttf' res = get_font_res(qidian_url) pattern = f'</style><span.*?{qidian_class}.*?>(.*?)</span>' num_list = re.findall(pattern, resp.text) num_list.pop(1) value_tupe = list() for num in num_list: value_tupe.append(get_encode(res, num)) print(value_tupe)