我有捕获网页所有内容的问题。在我使用常规浏览器登录outlook.com后,它应该在右侧显示收件箱消息:
然而,当我使用CasperJS时,它只是空白。有谁有想法吗?
我在脚本中包含了一个临时登录ID,如果可以的话,你可以测试一下,谢谢。
这是脚本:
casperjs --ssl-protocol=any outlook.js
我也试过像
这样的东西returnValues.forEach(function (tweet) {
if (tweet.text.search(/#|@/ig) > -1) {
var words = obj.text.split(' ');
var parsedTweetText = words.map(function (word) {
if (word.indexOf('#') === 0)
return '<span class="hashtag">' + word + '</span>';
else if (word.indexOf('@') === 0)
return '<span class="at-user">' + word + '</span>';
else
return word;
}).join(' ');
tweet.text = parsedTweetText;
}
});
我是否可以添加任何路径/插件来支持此CasperJS?
答案 0 :(得分:2)
Try the below code. You need to give/provide enough time to open web page
var casper = require('casper').create({
// verbose: true,
// logLevel: "info",
viewportSize: {width: 1280, height: 720},
pageSettings: {userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"}
});
casper.start('http://www.hotmail.com').then(function () {
console.log('got here');
});
casper.wait(1000, function () {
console.log('wait');
});
casper.then(function () {
this.sendKeys("[name='loginfmt']", 'peterwhite12345678@outlook.com');
this.sendKeys("[name='passwd']", '12345678peterwhite');
this.click("[type='submit']");
console.log('entering log in information');
});
casper.wait(20000, function () {
this.waitForSelector('#O365_MainLink_Settings', function () {
this.test.assertExists('#O365_Lync_ButtonID', 'Lync icon is visble, hence confirmed that page opened completely');
});
});
casper.waitForSelector(('._rp_52 > div:nth-child(4)'), function () {
if (this.visible("button._rp_o1:nth-child(2)")) {
console.log("Here we go, Right side is visible");
casper.capture('there is something.png');
}
else {
console.log("Nope")
}
});
casper.run();