PhantomJS抓取中文文档乱码

使用PhantomJs抓取百度标题乱码

var url="http://www.baidu.com"
var page=require('webpage').create()
page.open(url,function (status) {
    var title=page.evaluate(function () {
        return document.title;
    })
    console.log('Page title is ',title)
    phantom.exit()
})

结果:

解决方法:

phantomjs --output-encoding=gb2312 getHtmlTitle.js

原文地址:https://www.cnblogs.com/feiquan/p/11416310.html