Skip to content

Instantly share code, notes, and snippets.

@Rui-Santos
Forked from phoenixg/phantomjs-casperjs-wechat.js
Last active August 29, 2015 14:10
Show Gist options
  • Save Rui-Santos/f16ca06f211f28d34e66 to your computer and use it in GitHub Desktop.
Save Rui-Santos/f16ca06f211f28d34e66 to your computer and use it in GitHub Desktop.

Revisions

  1. @phoenixg phoenixg revised this gist Nov 12, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions phantomjs-casperjs-wechat.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    /**
    * 微信公众平台 fakeid 爬取
    * Usage: casperjs test.js 2814258914@qq.com password
    * Usage: casperjs test.js 123456@qq.com password
    * # phantomjs --version
    * 1.9.7
    * # casperjs --version
    @@ -60,7 +60,7 @@ loginUrl = '';
    // data: {
    // f: 'json',
    // imgcode: '',
    // username: '2814258914@qq.com',
    // username: '123456@qq.com',
    // pwd: '00fbd6d3e86be9c1f3cd8e7f2db17505'
    // }
    // }, function() {
  2. @phoenixg phoenixg revised this gist Nov 12, 2014. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions phantomjs-casperjs-wechat.js
    Original file line number Diff line number Diff line change
    @@ -41,12 +41,12 @@ loginUrl = '';

    //casper.start('https://mp.weixin.qq.com/', function() {
    // this.fillSelectors('form#login-form', {
    // 'input[id="account"]': "2814258914@qq.com",
    // 'input[id="account"]': "123456@qq.com",
    // 'input[id="password"]': passwd
    // }, false);

    // this.sendKeys('#account', '2814258914@qq.com');
    // this.sendKeys('#password', "nihaoma");
    // this.sendKeys('#account', '123456@qq.com');
    // this.sendKeys('#password', "123456");
    // this.click('#login_button');

    // this.sendKeys('input[id="account"]', "my_account");
    @@ -71,8 +71,8 @@ loginUrl = '';

    casper.start().thenOpenAndEvaluate('https://mp.weixin.qq.com/', function() {
    var f = document.querySelector('form');
    f.querySelector('input[id="account"]').value = '2814258914@qq.com';
    f.querySelector('input[id="password"]').value = 'nihaoma';
    f.querySelector('input[id="account"]').value = '123456@qq.com';
    f.querySelector('input[id="password"]').value = '123456';
    f.submit();
    });

  3. @phoenixg phoenixg created this gist Nov 12, 2014.
    94 changes: 94 additions & 0 deletions phantomjs-casperjs-wechat.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,94 @@
    /**
    * 微信公众平台 fakeid 爬取
    * Usage: casperjs test.js [email protected] 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"]': "[email protected]",
    // 'input[id="password"]': passwd
    // }, false);

    // this.sendKeys('#account', '[email protected]');
    // this.sendKeys('#password', "nihaoma");
    // 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: '[email protected]',
    // 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 = '[email protected]';
    f.querySelector('input[id="password"]').value = 'nihaoma';
    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();