【问题标题】:detect response body encoding with nodejs使用 nodejs 检测响应正文编码
【发布时间】:2012-01-11 15:36:24
【问题描述】:

我正在用 jsdom 和 jQuery 编写一个蜘蛛,比如the example

只有一个问题:当网页不是 UTF-8 编码并且响应头的 content-type 没有告诉我字符集时,我如何检测响应正文的编码?

我知道 node-iconv 可以提供帮助,但问题是我需要先知道编码

(额外问题:网络浏览器如何自动检测网页的编码?)

【问题讨论】:

    标签: node.js web-crawler


    【解决方案1】:

    npm install node-ice-charset-detector

    https://github.com/mooz/node-icu-charset-detector

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-18
      相关资源
      最近更新 更多