0
我一直在努力的一些代码来访问我的谷歌金融投资组合,但问题是我需要登录我的谷歌帐户。所以我做了这个:Casperjs谷歌登录不工作
var casper = require('casper').create();
casper.start('https://accounts.google.com/Login?hl=EN', function() {
this.evaluate(function(username, password) {
this.echo(this.getTitle());
document.querySelector('input#Email').value = username;
document.querySelector('#next').click();
document.querySelector('input#Passwd').value = password;
document.querySelector('#signIn').click();
}, 'GOOGLE EMAIL', 'PASSWORD');
});
casper.then(function() {
this.echo(this.getHTML()); // => 'The text included in the <h1 id=foobar>'
casper.thenOpen('https://www.google.com/finance/portfolio?action=view&pid=1&ei=pBrbVoDhM4iFjAGB-bKIAg', function() {
this.echo(this.getHTML());
this.echo(this.getTitle());
});
});
casper.run();
哪些不会登录我!
您是否收到任何类型的错误消息?如果是这样,请告诉我们。 – leDominatre
我没有收到任何错误消息。我的代码没有工作,因为我没有登录进程。 – Kpfromer
沿着屏幕截图查看错误的位置。您使用哪个PhantomJS版本?请注册到'resource.error','page.error','remote.message'和'casper.page.onResourceTimeout'事件([示例](https://gist.github.com/artjomb/4cf43d16ce50d8674fdf#file -2_caspererrors-JS))。也许有错误。 –