使用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