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))。也許有錯誤。 –