我使用此代码使用casperJS登录LinkedIn,但它不工作,登录后的标题应该是“Welcome!LinkedIn”,但它的返回“世界上最大的专业网络| LinkedIn”和文件。位置应该与网站网址不同,但是它在执行后会返回网站网址。CasperJS登录LinkedIn
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
pageSettings: {
loadImages: false, // The WebPage instance used by Casper will
loadPlugins: false, // use these settings
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4'
}
});
// print out all the messages in the headless browser context
casper.on('remote.message', function(msg) {
this.echo('remote message caught: ' + msg);
});
// print out all the messages in the headless browser context
casper.on("page.error", function(msg, trace) {
this.echo("Page Error: " + msg, "ERROR");
});
var url = 'https://www.linkedin.com/';
casper.start(url, function() {
// search for 'casperjs' from google form
console.log("page loaded");
this.test.assertExists('form#login', 'form is found');
this.fill('form#login', {
session_key: '[email protected]',
session_password: 'password'
}, true);
});
casper.thenEvaluate(function(){
console.log("Page Title " + document.title);
console.log("Your name is " + document.location);
});
casper.run();
我在做什么错在这段代码?
你测试了你发布的代码吗?我得到这个错误'[error] [phantom]等待超时5000ms过期,退出。 超过5000ms的等待超时退出。 ' – scottydelta
是的,它的工作原理,但我是法国人,所以也许LinkedIn不会为我提供相同的页面URL。尝试等待(2000,function(){}); –
有没有新闻?谢谢。 –