Skip to content

Instantly share code, notes, and snippets.

@phoenixg
Last active September 23, 2016 07:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save phoenixg/dabdd7869b91e5ff80d7 to your computer and use it in GitHub Desktop.
Save phoenixg/dabdd7869b91e5ff80d7 to your computer and use it in GitHub Desktop.
/**
* 微信公众平台 fakeid 爬取
* Usage: casperjs test.js 123456@qq.com password
* # phantomjs --version
* 1.9.7
* # casperjs --version
* 1.1.0-beta3
--ignore-ssl-errors=yes ???
*/
// todo thenOpen()
var casper = require('casper').create({
logLevel: 'debug',
verbose: true,
pageSettings: {
loadImages: false, // do not load images
loadPlugins: false // do not load NPAPI plugins (Flash, Silverlight, ...)
},
clientScripts: [
'./jquery-1.11.1.min.js'
],
});
casper.userAgent('Mozilla/5.0 (Windows NT 6.1; rv:29.0) Gecko/20100101 Firefox/29.0');
// removing default options passed by the Python executable
casper.cli.drop("cli");
casper.cli.drop("casper-path");
if (casper.cli.args.length === 0 && Object.keys(casper.cli.options).length === 0) {
casper.echo("No arg nor option passed").exit();
}
var usr = casper.cli.get(0);
var passwd = casper.cli.get(1);
var cookieFile = casper.cli.get(2);
loginUrl = '';
//casper.start('https://mp.weixin.qq.com/', function() {
// this.fillSelectors('form#login-form', {
// 'input[id="account"]': "123456@qq.com",
// 'input[id="password"]': passwd
// }, false);
// this.sendKeys('#account', '123456@qq.com');
// this.sendKeys('#password', "123456");
// this.click('#login_button');
// this.sendKeys('input[id="account"]', "my_account");
// this.sendKeys('input[id="password"]', "my_password");
// this.click('#login_button');
//});
// casper.start().thenOpen('https://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN', {
// method: "post",
// data: {
// f: 'json',
// imgcode: '',
// username: '123456@qq.com',
// pwd: '00fbd6d3e86be9c1f3cd8e7f2db17505'
// }
// }, function() {
// this.echo("POST request has been sent.");
// this.echo('Page url is ' + this.getCurrentUrl());
// this.echo('Page title is ' + this.getTitle());
// });
casper.start().thenOpenAndEvaluate('https://mp.weixin.qq.com/', function() {
var f = document.querySelector('form');
f.querySelector('input[id="account"]').value = '123456@qq.com';
f.querySelector('input[id="password"]').value = '123456';
f.submit();
});
casper.then(function() {
this.echo('Page url is ' + this.getCurrentUrl());
this.echo('Page title is ' + this.getTitle());
});
// casper.thenOpen(url2);
// casper.thenOpen(url3);
// casper.thenOpen(url4);
casper.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment