var LOGIN_URL, LOGIN_USERNAME, LOGIN_PASSWORD, casp;
casp = require('casper').create({
viewportSize: {
width: 1024,
height: 768
},
verbose: true,
logLevel: 'warning'
});
var fs = require('fs');
casp.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
phantom.cookiesEnabled = true;
phantom.javascriptEnabled = true;
if (!casp.cli.has('username') && !casp.cli.has('password')) {
casp.echo('Usage: $ casperjs sfdclogin.casper.js --username=USERNAME --password=PASSWORD [--prod]').exit(-1);
}
if (casp.cli.has('prod')) {
LOGIN_URL = 'https://sellercentral.amazon.com/gp/sign-in/sign-in.html?destination=https%3A%2F%2Fsellercentral.amazon.com%2Fhz%2Fhome';
} else {
LOGIN_URL = 'https://sellercentral.amazon.com/gp/sign-in/sign-in.html?destination=https%3A%2F%2Fsellercentral.amazon.com%2Fhz%2Fhome';
}
LOGIN_USERNAME = casp.cli.get('username');
LOGIN_PASSWORD = casp.cli.get('password');
casp.start(LOGIN_URL, function () {
'use strict';
// this.enableCookieSupport();
// phantom.cookiesEnabled = true;
this.log('Logging in', 'debug');
});
casp.then(function () {
this.fill('form', {
'username': LOGIN_USERNAME,
'password': LOGIN_PASSWORD
}, true);
this.log('Logged in', 'debug');
});
casp.then(function () {
'use strict';
this.echo('We\'re logged in. Now we can do more stuff like take a screenshot!');
this.echo(this.getHTML());
});
casp.run();
casperjs --ssl-protocol=tlsv1 tt.js --username=dealschic@gmail.com --password=zyz14607terr >> 22.html
下面是从屏幕键盘读取值,代码部分为:
this.echo("What is the ZIP code of the billing address you registered with your credit or debit card number that ends in 13?");
zipcode = system.stdin.readLine();
var LOGIN_URL, LOGIN_USERNAME, LOGIN_PASSWORD, casp;
casp = require('casper').create({
viewportSize: {
width: 1024,
height: 768
},
verbose: true,
logLevel: 'warning'
});
var fs = require('fs');
var system = require('system');
casp.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
phantom.cookiesEnabled = true;
phantom.javascriptEnabled = true;
if (!casp.cli.has('username') && !casp.cli.has('password')) {
casp.echo('Usage: $ casperjs sfdclogin.casper.js --username=USERNAME --password=PASSWORD [--prod]').exit(-1);
}
if (casp.cli.has('prod')) {
LOGIN_URL = 'https://sellercentral.amazon.com/gp/sign-in/sign-in.html?destination=https%3A%2F%2Fsellercentral.amazon.com%2Fhz%2Fhome';
} else {
LOGIN_URL = 'https://sellercentral.amazon.com/gp/sign-in/sign-in.html?destination=https%3A%2F%2Fsellercentral.amazon.com%2Fhz%2Fhome';
}
LOGIN_USERNAME = casp.cli.get('username');
LOGIN_PASSWORD = casp.cli.get('password');
casp.start(LOGIN_URL, function () {
'use strict';
// this.enableCookieSupport();
// phantom.cookiesEnabled = true;
this.log('Logging in', 'debug');
});
casp.then(function () {
this.fill('form', {
'username': LOGIN_USERNAME,
'password': LOGIN_PASSWORD
}, true);
this.log('Logged in', 'debug');
});
casp.then(function () {
this.echo("What is the ZIP code of the billing address you registered with your credit or debit card number that ends in 13?");
zipcode = system.stdin.readLine();
this.fill('form', {
'dcq_question_subjective_1': zipcode,
}, true);
this.log('Logged in', 'debug');
});
casp.then(function () {
'use strict';
this.echo('We\'re logged in. Now we can do more stuff like take a screenshot!');
this.echo(this.getHTML());
});
casp.run();