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

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

月光魔力鸭

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


感谢支持!

赞赏支持
提交评论
评论信息 (请文明评论)
暂无评论,快来快来写想法...
推荐
这事其实很简单,就是调用adb几个命令而已.. 主要是有时候想用的时候总感觉差点啥,东拼西凑才弄出来,这里记录下,哪怕就是贴个地址的,也比记在脑子里强。
跑了一个千库网的自动签到,在windows上测试的时候好好的,图片也没问题,可是放到linux服务器就不行了,总是登录不上不说,图片都不一样
从豆瓣转到网易云后,发现了不少好听的歌曲,然鹅..当我想把这些歌拿下来扔车上听的时候发现竟然不允许下载..能听不能下?这不科学,作为一名程序猿,必然要迎难而上啊.
在日常开发中,经常会频繁的做一些重复性的操作,作为一名程序员,解放双手的时刻到了
经常会遇到需要系统重启后自动执行的一些任务,在windows 上可以将对应的程序打包成service 然后自启动即可
最近由于系统需要一些数据进行测试,但是正常的流程都是下载pdf ,打印pdf,然后通过涂写答题卡,将涂写的扫描上传..太麻烦了,想做成简单点,通过程序直接生成..卡在了pdf转图片上,今天抽空找了下库,通过gm可以将pdf转为图片,起码第一步已经实现了,后边的涂学号之前已经做过了。
记录下通过nodejs调用imagemagick 的时候发现的一个错误,command failed -- crop .
在我们做运维或者小工具的时候,总会有些需要提醒的事情,比如服务器宕机或者天气提醒,但是发email又会不够及时或者可能会忽略,那么短信就是一个不错的选择了