Javascript 为什么可以';我的CasperJS脚本是否登录到Quora?
这是我的代码:Javascript 为什么可以';我的CasperJS脚本是否登录到Quora?,javascript,web-scraping,screen-scraping,phantomjs,casperjs,Javascript,Web Scraping,Screen Scraping,Phantomjs,Casperjs,这是我的代码: var casper = require('casper').create({ verbose: true, logLevel: 'debug' }); casper.start('http://www.quora.com', function() { this.click('input.submit_button'); this.echo("page loaded");
var casper = require('casper').create({
verbose: true,
logLevel: 'debug'
});
casper.start('http://www.quora.com', function()
{
this.click('input.submit_button');
this.echo("page loaded");
this.test.assertExists('form.inline_login_form', 'form is found');
this.fill('form.inline_login_form',{email:'xxxxxx@gmail.com',password:'xxxx'},false);
}
);
casper.then(function(){
this.click('input.submit_button');
});
casper.then(function(){
this.capture('google.png', {
top: 0,
left: 0,
width:0,
height:0
});
this.echo("Page Title " + this.getTitle());
});
casper.run();
这是捕获方法生成的图像:
为什么不登录?
id和密码正确。您应该在请求之间添加一些等待语句。可能有一些ajax你没有足够的时间被解雇。您还需要添加一个用户代理。有时,如果他们嗅出了你的用户代理,就会提供不同版本的网页 试试这个,一定能奏效:
var casper = require('casper').create({
viewportSize: {
width: 1080,
height: 768
}
});
var email = "xxx@abc.com";
var pass = "********";
casper.start('http://www.quora.com', function()
{
this.click('input.submit_button');
this.echo("page loaded");
this.test.assertExists('form.inline_login_form', 'form is found');
this.fill('form#__w2_b3oUn76_login_form',{email:'email',password:'pass'},true);
});
casper.waitForSelector("form[name=search_form] input[name='search_input']",
function(){
this.capture('google.png');
this.echo("Page Title " + this.getTitle());
});
casper.run();
尝试将捕获移动到
中,然后使用echo将捕获移动到。我尝试了,但没有成功。这就是我使用的修改过的代码:我仍然得到相同的捕获@六边形