记录千库网的一次自动登录

记录千库网的一次自动登录

月光魔力鸭

2018-09-12 10:24 阅读 1299 喜欢 0 自动登录 千库网

写文章总会需要一些素材,但是好多素材都是收费或有限制的,还是我要求不高,在千库网看了下还不错,有各签到还送VIP,于是就有了想法....

想到就干,由于之前有过经验,所以选用的还是: phantomjs + casperjs

先分析下步骤:

所以难点就在登录上,根据分析找到千库网的QQ登录地址: http://588ku.com/index.php?m=login&a=snsLogin&type=qq&source= 只需要访问这个地址,然后点击登录,再页面中再次访问千库网首页就可以发现已经登录上了。

代码如下:

phantom.outputEncoding = 'utf8';

var url = 'http://588ku.com/';

var casper = require('casper').create({
    verbose: true,
    logLevel: "debug",
    pageSettings: {
         loadImages:  true,        
         loadPlugins: true,    
         userAgent: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2729.4 Safari/537.36'
    }
});

var user = casper.cli.args[0],
    pwd = casper.cli.args[1];

casper.start().thenOpen('http://588ku.com/index.php?m=login&a=snsLogin&type=qq&source=',function(){});
casper.withFrame(0,function(){
    this.capture('1.png');
    this.echo('登录中...')
    this.click('#switcher_plogin');//切换
    this.wait(15000);
});
casper.withFrame(0,function(){
    this.capture('2.png');
    this.fillSelectors('form#loginform',{
        '#u' : user,
        '#p' : pwd
    });
    this.wait(15000);
});
casper.withFrame(0,function(){
    this.capture('3.png');
    this.click('form#loginform input[type="submit"]');
    this.wait(1000);
    this.capture('4.png');
    this.wait(15000);
});
casper.thenOpen(url,function(){
    this.echo('进入'+url);
    this.wait(15000);
    this.capture('5.png');
    this.waitForSelector('.already-sign-but');
});

casper.then(function(){
    this.echo('点击签到');
    this.click('a.already-sign-but');
    this.wait(12000);
});
casper.then(function(){
    if(this.exists('.signIn-btn')){
        this.echo('还未签到,正在签到中...')
    }
});
casper.then(function(){
    this.click('.signIn-btn');
    this.wait(11000);
});
casper.then(function(){
    this.capture('res.png');
    this.echo('签到结束,查看 res.png 图片');
});
casper.then(function(){
    this.exit();//退出
})

casper.run();

在来一张截图:

image.png

转载请注明出处: https://chrunlee.cn/article/auto-login-qianku.html


感谢支持!

赞赏支持
提交评论
评论信息 (请文明评论)
暂无评论,快来快来写想法...
推荐
当我们想实现一个自己的库或模块后,发布的话,需要发布到npm上才能下载。以下是具体步骤
使用nodejs连接ftp,进行ftp的操作,包括列表、上传、下载以及速率等。
在开发的时候,经常会有css js 文件的变更,然后部署后发现没有起到作用,最终发现是缓存的问题,如何来方便的解决
通过pm2来实现nodejs应用的集群,不过我之前没做session共享,导致.. 登录不上啊 啊啊啊,无奈,又重新对redis进行了集成。
thinkjs框架使用ueditor记录。
在开发项目过程中,经常需要将开发的项目部署到服务器上,但是每个环境都有每个环境的配置等等,如果每次打包的时候都要去调整(可能删除、替换等),那就很烦人了,这里分享下自己实现的几个简单的小工具(当然这个工具可能只对我自己有用),希望能够帮到你。
之前在知乎上有看到,基本上都是一致的,这里提供一个nodejs版本的针对微信内dat文件进行处理恢复为图片的方法。
在通过axios读取页面的时候,经常会碰到gbk的编码,如果不进行转化的话,在获取信息或读取上都会很麻烦。