更多>>关于我们
西安鲲之鹏网络信息技术有限公司从2010年开始专注于Web(网站)数据抓取领域。致力于为广大中国客户提供准确、快捷的数据采集相关服务。我们采用分布式系统架构,日采集网页数千万。我们拥有海量稳定高匿HTTP代理IP地址池,可以有效获取互联网任何公开可见信息。
您只需告诉我们您想抓取的网站是什么,您感兴趣的字段有哪些,你需要的数据是哪种格式,我们将为您做所有的工作,最后把数据(或程序)交付给你。
数据的格式可以是CSV、JSON、XML、ACCESS、SQLITE、MSSQL、MYSQL等等。
更多>>技术文章
最近在做一个58房产数据的采集项目时,发现58房产类的电话号码是被加密过的,表现出来的现象是,在浏览器里查看页面上的电话号码时是正常显示的,但是在html源码里,电话号码的部分却显示为加密的文字。如下图所示:
经过鲲鹏技术人员的分析,发现这里电话号码的加密(混淆)是通过一种特殊字体实现的,本例中该字体名称是”fangchan-secret“,其字体数据就放在如下图所示的一个base64字符串中:
但是,如何从中得到真实的电话号码数字呢?
类似的数据混淆反采集手段我们曾在“”汽车之家”和“美团外卖”采集项目中遇到过,例如,汽车之家网站将一些常见的字符采用了特殊字体显示,由于该字体文件是固定的(如下图所示),因此很容易构造出“特殊编码->明文字符”映射表,进而将特殊编码还原成明文。
分析本例中的字体文件,可以看到0-9这10个数字被做成了特殊字体,如下图所示。
和汽车之家的情况不同的是本例中字体文件是动态生成的(字符对应的编码是变化的,对比下图,是刷新页面后新的字体文件截图),由于字符编码每次都在变化,因此无法通过构造固定的映射表来还原字符。
但好在字符的顺序是固定的,排在字符列表第一位的始终是0,排在最后一位的始终是9。所以根据这一规律,我们还是能够还原出这些特殊字符对应的明文字符数字。
下面是测试代码:
# coding: utf-8 # 58phone_crack.py # 58同城电话号码字体混淆破解测试 import re import base64 import StringIO from fontTools.ttLib import TTFont def test(): # 字体base64数据 font_base64_data = 'AAEAAAALAIAAAwAwR1NVQiCLJXoAAAE4AAAAVE9TLzL4XQjtAAABjAAAAFZjbWFwq8B/ZwAAAhAAAAIuZ2x5ZuWIN0cAAARYAAADdGh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gAGYAcgBvAG0AIABGAG8AbgB0AGUAbABsAG8AIABwAHIAbwBqAGUAYwB0AC4AaAB0AHQAcAA6AC8ALwBmAG8AbgB0AGUAbABsAG8ALgBjAG8AbQAAAAIAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwECAQMBBAEFAQYBBwEIAQkBCgELAQwAAAAAAAAAAAAAAAAAAAAA' # 打开字体文件 font = TTFont(StringIO.StringIO(base64.b64decode(font_base64_data))) # 建立“字符顺序-编码”映射表 chars_codes_map = {} # 按字符顺序遍历 for i, glyph_name in enumerate(font.getGlyphOrder()): # 获取对应字符的编码 for char_code, _glyph_name in font.getBestCmap().items(): if glyph_name == _glyph_name: # 找到匹配 chars_codes_map[char_code] = str(i - 1) break # 测试还原 phone_enc = '麣餼麣龒龤閏鑶鑶龥驋龤' phone_nums = [] for char_code_base16 in re.compile(r'&#x([a-z\d]{4});').findall(phone_enc): char_code_base10 = int(char_code_base16, base=16) phone_nums.append(chars_codes_map[char_code_base10]) print '还原后的号码是:', ''.join(phone_nums) if __name__ == '__main__': test()
下面是网页截图和测试运行结果的对比图: