phantom.casperPath = './node_modules/casperjs';
phantom.injectJs('./node_modules/casperjs/bin/bootstrap.js');
var fs = require('fs')
var casper = require('casper').create({
pageSettings: {
loadImages: false,//The script is much faster when this field is set to
false
loadPlugins: false,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36'
}
});
//open Facebook
casper.start().thenOpen("https://dcid.dcinside.com/join/login.php?",
function() {
console.log("dcinside website opened");
});
//login
casper.then(function() {
console.log("Log in with the appropriate id and pw.");
this.evaluate(function() {
document.getElementById("email").value = "chermy018";
document.getElementById("pass").value = "kl424321";
document.getElementById("loginbutton").children[0].click();
});
});
var request = require('request'),
cheerio = require('cheerio');
var url = "http://gallog.dcinside.com/inc/_mylog.php?gid=chermy018&oneview=Y&cid=59&page=1";
request(url, function(err, res, html) {
if (!err) {
var $ = cheerio.load(html);
}
console.log(html);
})
casper.run();
为了解析我的日记超过800页,我看起来解析方法,其中可以处理解析登录所需的页面。和修改后的原版似乎看起来像是在网站上解析我的日记。通过引用我所采取的,它应该通过命令" phantomjs filename"来运行。但是cmd无法处理phantomjs命令。我已经安装过#phantomjs'和' casperjs'。你能纠正代码,如果它有目的问题和什么可以解决症状。