上一篇文章中使用nodejs程序解析了网页编码为gbk,gb2312,以及utf-8的情况,这里面有三种特殊的乱码情况需要单独的说明一下.
1,网页编码为utf-8,但是解析为乱码,代表网站为,
由于iconv-lite的说明中支持如下的编码方式:
Currently only a small part of encodings supported:
All node.js native encodings: 'utf8', 'ucs2', 'ascii', 'binary', 'base64'. Base encodings: 'latin1' Cyrillic encodings: 'windows-1251', 'koi8-r', 'iso 8859-5'. Simplified chinese: 'gbk', 'gb2313'.Other encodings are easy to add, see the source. Please, participate
因此对于上述出现的网页编码,只有自己添加解码方式加以解决了。
总之要写一个通用的爬虫程序还有很长的路要走。