phantomjs 抓

用phantomjs抓取html乱码的解决方案:

phantomjs–output-encoding=gbktest.js?url=www.coding123.net

这两个参数可以指定编码 …

–output-encoding=encodingsets the encoding used for terminal output (default is utf8).–script-encoding=encodingsets the encoding used for the starting script (default is utf8).

设置成 GBK 就可以了 …

或者

phantom.outputEncoding="gbk";

用phantomjs截图时中文乱码的解决方案:

用phantomjs去截取中文页面的网站可能会出现乱码的情况,也就是截图中中文的位置全是方框。

解决办法就是安装字体。

在centos中执行:yum install bitmap-fonts bitmap-fonts-cjk

在ubuntu中执行:sudo apt-get install xfonts-wqy

这样再去截图中文的页面就不会出现一堆的方框了。

版权声明:本文为博主原创文章,,未经博主允许不得转载。

何不去远方!昆明呀——赶一个花海;

phantomjs 抓

相关文章:

你感兴趣的文章:

标签云: