1、选择网址58同城
2、按F12查看元素
3、将鼠标指到数字上发现如下所示
数字显示乱码
我搜索一下fangchan-secret
发现有很长的字符串前面有base64,断定这是base64加密,然后解密这段字符串就能实现反爬
代码如下:
def get_html(self,url): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', } html = requests.get(url, headers=headers).text return html
def get_xml(self,html): base64_str = re.search(r'base64,(.*?)\)', html, re.S).group(1) base64_str_decode = base64.b64decode(base64_str) filr_name = "58.ttf" with open(filr_name, 'wb') as f: f.write(base64_str_decode) font = TTFont('58.ttf') # 打开本地的ttf文件 font.saveXML('58.xml') # 转换成xml
3、打开xml文件
4、解析cmap中的内容得到字典
def get_dict(self,html): base64_str = re.search(r'base64,(.*?)\)', html, re.S).group(1) base64_str_decode = base64.b64decode(base64_str) filr_name = "58.ttf" with open(filr_name, 'wb') as f: f.write(base64_str_decode) font = TTFont('58.ttf') # 打开本地的ttf文件 font.saveXML('58.xml') # 转换成xml cmap = font['cmap'].getBestCmap() newdict = {} for i in cmap: pat = re.compile(r'(\d+)') values = int (re.search(pat,cmap[i])[1]) - 1 keys = hex(i) newdict[keys] = values return newdict
5、字典内容
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。