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

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

月光魔力鸭

2018-09-12 10:24 阅读 1386 喜欢 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


感谢支持!

赞赏支持
提交评论
评论信息 (请文明评论)
暂无评论,快来快来写想法...
推荐
目前了解的有两个模块可以实现二维码的模块,一个是node-qrcode ,这个算是比较大众的,不过环境比较复杂,所以...连看都没看;还有一个是小众的 qr-image ,这个比较简单,没有其他环境依赖,安装即可用,因为要实现一个简单的在线二维码生成,就先用这个试试水了
我们项目一直在使用puppeteer 生成pdf ,整体的思路是没有问题的,而且在开发环境运行了好久了,但是部署后总会有各种各样的报错。各种so文件找不到等等 。
通过nodejs来进行爬取页面的内容,这里简单试试做个小任务..
近期有个小工具,需要使用到本地数据库,想使用sqlite ,本来以为是个手到擒来的活... 没成想卡在了开始上。
开始入手webpack ,直接看的官方文档和demo,对于自动刷新这部分还是希望通过express 加载插件来控制,但是文档没有提供,经过参考github上其他高玩的套路,最终整理了一个基础的配置版本。
docker镜像中的puppeteer安装
学习爬虫的时候突然有想到想做一个音乐播放小站,可以给自己或朋友听,但是音乐哪里来呢??想到自己常听的豆瓣FM,就越发的想把这些音乐都拿下来,因此有了下文通过豆瓣FM批量抓取上万首音乐,目前已经3W+。
前段时间做了个微信小程序反编译的小东西,不过因为功能不全,没加分包处理,正好处理下加上,又考虑到后续可能的更新情况,准备上手增加下更新功能。