renrenlogin

0.0.6 • Public • Published

renrenlogin

登录人人网

Install:

npm install renrenlogin

Usage:

1.用账号密码登录

var fs=require('fs');

var Login=new (require('renrenlogin').INST)();

//如果账号是具有个人和公共主页双重身份的,

// 要登公共主页时把isPage设为true,其他情况都可不设isPage或设为false

var account={

email:'账号',

passwd:'密码',

isPage:false

};

Login.setAccount(account);

Login.onekeyLogin(function(err,info){

console.log(info.logined);

//把登录后的用户信息保存到文件中

fs.writeFileSync('info.txt',JSON.stringify(info,null,4), 'utf8');

});

2.从已保存到文件中的Cookie登录

//从持久化的cookie信息直接登录,不需要提交密码信息(如果发现cookie已经失效了,则会重新尝试密码登录)

function loginFromCookie(){

var account=JSON.parse(fs.readFileSync('info.txt','utf8'));

Login.setAccount(account);

Login.onekeyLogin(function(err,info){

    console.log(info.logined);

});

}

返回后的info中含有Cookie对象,这是request模块的内置cookie管理器。

后续要发起请求时建议使用request模块,只需把这个返回的Cookie设为request的默认cookie即可。

var request=require('request');

request=request.defaults({

jar:info.Cookie

});

request('http://www.renren.com',function(){});

///...

有问题邮件我786647787@qq.com

Readme

Keywords

Package Sidebar

Install

npm i renrenlogin

Weekly Downloads

0

Version

0.0.6

License

MIT

Last publish

Collaborators

  • sxyizhiren